# Please replace German umlauts in URLs with their respective digraphs

**URL:** https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489
**Category:** Feature
**Tags:** translation
**Created:** [27 Enero, 2015 14:56 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489 "2015-01-27T14:56:44Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)
#### Post date: [27 Enero, 2015 14:56 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/1 "2015-01-27T14:56:44Z")

</div>

When generating topic URLs from titles, German [umlauts](http://en.wikipedia.org/wiki/Umlaut_%28linguistics%29) could be “translated” better.

**Currently:**

Title:

```
Kürzest mögliche Logging-Klasse

```

URL:

```
/kurzest-mogliche-logging-klasse

```

([Example](http://entwicklergate.de/t/kurzest-mogliche-logging-klasse/29))

**Suggestion:**

Replace umlauts with their respective [digraphs](http://en.wikipedia.org/wiki/Digraph_%28orthography%29):

Title:

```
Kürzest mögliche Logging-Klasse

```

URL:

```
/kuerzest-moegliche-logging-klasse

```

I.e.:

> ä =\> ae  
> ö =\> oe  
> ü =\> ue  
> ß =\> ss

Most likely there is some kind of automatic conversion that would work for other languages, too.

---

<div class="post-metadata">

### Author: ![thangngoc89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thangngoc89/32/115436_2.png) [@thangngoc89](https://meta.discourse.org/u/thangngoc89)
#### Post date: [27 Enero, 2015 15:16 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/2 "2015-01-27T15:16:32Z")

</div>

You can create your own language slug rules with a custom plugin.  
Check this  
[https://github.com/thangngoc89/discourse-vietnamese-slug](https://github.com/thangngoc89/discourse-vietnamese-slug)

In case you’re too lazy with all the character, here is a good project for slug

> <https://github.com/cocur/slugify/blob/master/src/Slugify.php>

---

<div class="post-metadata">

### Author: ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)
#### Post date: [27 Enero, 2015 15:23 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/3 "2015-01-27T15:23:17Z")

</div>

> [@thangngoc89](#):
>
> You can create your own language slug rules with a custom plugin.Check this [GitHub - thangngoc89/discourse-vietnamese-slug: Add Vietnamese Slug to Discourse · GitHub](https://github.com/thangngoc89/discourse-vietnamese-slug)

Thanks. From a quick look, it seems that in the [source code](https://github.com/thangngoc89/discourse-vietnamese-slug/blob/master/plugin.rb), one character is replaced by one other character.

Since I need to replace one character by two characters, I would have to modify the code.

On the other hand, I have not the slightest clue how to develop in Ruby. So I better wait until (if ever) this goes into the main Discourse sources.

---

<div class="post-metadata">

### Author: ![thangngoc89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thangngoc89/32/115436_2.png) [@thangngoc89](https://meta.discourse.org/u/thangngoc89)
#### Post date: [27 Enero, 2015 15:35 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/4 "2015-01-27T15:35:19Z")

</div>

Acctually, I’m a noob in Ruby. But I can write that code quite easy (with a little help in plugin part).  
Ideally, you can make a simple array like

```
ä : ae
ö : oe
ü : ue
ß : ss

```

With a loop, you can replace all text in title before pass it to Discourse slug generator

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [27 Enero, 2015 15:49 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/5 "2015-01-27T15:49:38Z")

</div>

I could probably submit a patch for that.  
The slugs are calculated in [slug.rb](https://github.com/discourse/discourse/blob/master/lib/slug.rb). It already contains exceptions for `zh_CN` and `ja` and there seems to be an [open pull request for Vietnamese](https://github.com/discourse/discourse/pull/3013).

@sam I guess there will be a lot more languages with the same problem. How should we handle this? Should I just submit a simple patch for German or are you going to use a gem like [babosa](https://github.com/norman/babosa)? Any other ideas?

---

<div class="post-metadata">

### Author: ![thangngoc89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thangngoc89/32/115436_2.png) [@thangngoc89](https://meta.discourse.org/u/thangngoc89)
#### Post date: [27 Enero, 2015 15:54 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/6 "2015-01-27T15:54:30Z")

</div>

> [@gerhard](#):
>
> an open pull request for Vietnamese.

I’ll withdraw that pull request. I created the slug plugin myself to work around that

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [26 Febrero, 2015 20:45 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/7 "2015-02-26T20:45:27Z")

</div>

@sam and @techAPJ: Can you please help me out here?

I’ve been looking into this a little bit. It looks like I have a few options for solving this:

**Option 1**  
Add the following transliteration rules to `server.de.yml` and let the existing transliteration replace the German umlauts:

```yaml
  i18n:
    transliterate:
      rule:
        Ä: "AE"
        Ö: "OE"
        Ü: "UE"
        ß: "ss"
        ä: "ae"
        ö: "oe"
        ü: "ue"

```

But I guess I would have to add those to `server.en.yml` as well, otherwise they would get lost at the next pull from Transifex. I’m not feeling comfortable in doing that. Why should the translators of all the other languages have to worry about this? I’m not even sure why we already have some rules in there…

> <https://github.com/discourse/discourse/blob/main/config/locales/server.en.yml#L23-L29>

**Option 2**  
Add an additional, language specific translation file (e.g. `transliterations.de.yml`) that just contains the transliteration rules and is not managed in Transifex.

**Option 3**  
Replace the German umlauts within [slug.rb](https://github.com/discourse/discourse/blob/master/lib/slug.rb). Doing this with a regex wouldn’t be that hard since there are only 7 characters to replace. But, this feels wrong on so many levels. What if other languages want to do the same? I imagine this would become ugly quite fast.

**Option 4**  
Use _stringex_ like it’s already done for Simplified Chinese. According to the documentation it should even have German transliterations out-of-the-box. However, I couldn’t get it working. Somehow it didn’t use the locale files that should come with stringex. :frowning: It only used the two translations from `server.en.yml`.

> <https://github.com/discourse/discourse/blob/main/config/locales/server.en.yml#L18-L21>

What I also like about it is the localization of stringex conversations:

> It is possible to localize the different conversions and unidecoding in Stringex, so for example “100%” becomes “100 percent” in English and “100 prozent” in German.

Currently symbols like `%` are always removed when the slug is created. Replacing it by e.g. “percent” would be great.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [26 Febrero, 2015 21:22 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/8 "2015-02-26T21:22:11Z")

</div>

I think we should go for options 2

`transliterations.de.yml` seems like the cleanest way to solve this.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [1 Marzo, 2015 23:25 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/9 "2015-03-01T23:25:30Z")

</div>

German umlauts are now handled correctly if the default locale of the forum is “de”:

[https://github.com/discourse/discourse/commit/8a236c06e282e7bc64e2bf963d52ade261755255](https://github.com/discourse/discourse/commit/8a236c06e282e7bc64e2bf963d52ade261755255)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [1 Marzo, 2015 23:26 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/10 "2015-03-01T23:26:20Z")

</div>

Closing as the PR was now merged, thanks @gerhard!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [1 Marzo, 2015 23:26 UTC](https://meta.discourse.org/t/please-replace-german-umlauts-in-urls-with-their-respective-digraphs/24489/11 "2015-03-01T23:26:26Z")

</div>


