Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

German Umlaut support #85

Closed
TobitRE opened this issue Oct 7, 2019 · 2 comments
Closed

German Umlaut support #85

TobitRE opened this issue Oct 7, 2019 · 2 comments

Comments

@TobitRE
Copy link

TobitRE commented Oct 7, 2019

It would be great if slugify support German umlaut like

slugify_de('ÜBER Über slugify') # UEBER-Ueber-slugify

awesome-slugify does a great job but the development hass been stoped.

@un33k
Copy link
Owner

un33k commented Oct 10, 2019

@TobitRE You can achieve this by pretranslation replacements. Mind you that you may be bound to lowercase slugs only.

txt = 'ÜBER Über German Umlaut'
r = slugify(txt, replacements=[['Ü', 'UE'], ['ü', 'ue']])
self.assertEqual(r, "ueber-ueber-german-umlaut")

Or you can pass your own replacement list.

GERMAN_UMLAUT = [
    [u'ä': u'ae'],   
    [u'ö': u'oe]',   
    [ u'ü': u'ue'],  
}
txt = 'ÜBER Über German Umlaut'
r = slugify(txt, replacements=GERMAN_UMLAUT)
self.assertEqual(r, "ueber-ueber-german-umlaut")

Alternatively, you can (v3.0.6+)

from slugify import PRE_TRANSLATIONS
txt = 'ÜBER Über German Umlaut'
r = slugify(txt, replacements=PRE_TRANSLATIONS)
self.assertEqual(r, "ueber-ueber-german-umlaut")

@kennell
Copy link

kennell commented Oct 12, 2021

^ the code example above has several syntax errors. Here is a Python3 code example for people stumbling on this issue via Google:

from slugify import slugify
GERMAN_UMLAUT = [
    ['ä', 'ae'],
    ['ö', 'oe'],
    ['ü', 'ue'],
]
slugify('Baden-Württemberg', replacements=GERMAN_UMLAUT)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants