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

Add German locale #87

Merged
merged 1 commit into from
Jul 26, 2020
Merged

Add German locale #87

merged 1 commit into from
Jul 26, 2020

Conversation

schwigri
Copy link
Contributor

In German, letters with an umlaut are transcribed without a diacritic and given an "e" when the diacritic cannot be used (e.g. in slugs). For example, see these pages (from both Germany and German-speaking Switzerland):

Page name Slug
Staatsministerin für ... staatsministerin-fuer...
Pass & Identitätskarte pass-identitaetskarte
Zürich www.zuerich.com

@simov simov merged commit 56053d9 into simov:master Jul 26, 2020
@simov
Copy link
Owner

simov commented Jul 26, 2020

Thanks 👍

@Soetens
Copy link

Soetens commented Mar 17, 2021

This does not seem to work for me, I see the correct conversions in an array but ö still returns as o and not oe.

url = slugify(val, {
locale: locale,
lower : true
});

@schwigri
Copy link
Contributor Author

@Soetens, please check your slugify version as well as the string passed to locale (it must only be de; for example, de_CH will not work).

You can see an example here: https://codesandbox.io/s/slugify-test-ppc27?file=/src/App.js

@Trott
Copy link
Collaborator

Trott commented Mar 17, 2021

I wonder if ö being transliterated to oe ought to be the default (and so on for other letters containing umlauts). I would imagine German is the most frequent place to find ö. I'm not sure how it is typically transliterated when it appears in Swedish and other languages.

@schwigri
Copy link
Contributor Author

Looking back, I also wonder if the capital variations should be converted to capital followed by lower case. For example, I think it would be better if slugify("Örlikon", { locale: "de" }) === "Oerlikon", and then allow users to uppercase or lowercase themselves.

Of course, this means that when capital umlaut occurs in the middle of a word, it would have to be handled (e.g. .toLocaleUpperCase() if that's the intention). But, that allows the most flexibility as it is more difficult to convert the second capital to lowercase while keeping the first.

@schwigri
Copy link
Contributor Author

I wonder if ö being transliterated to oe ought to be the default (and so on for other letters containing umlauts). I would imagine German is the most frequent place to find ö. I'm not sure how it is typically transliterated when it appears in Swedish and other languages.

It appears that in Swedish and Hungarian, the umlaut characters are typically transcribed without adding an e.

Page Name Slug
Regeringsförklaringen .../regeringsforklaringen...
Rättsliga dokument .../rattsliga-dokument/
Miniszterelnök .../miniszterelnok

Because of that, as well as existing usage, I'd be against changing default behavior.

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

Successfully merging this pull request may close these issues.

4 participants