I am trying to get German characters back in a German. Right now, I am using a simple diacritics table to get it. Is it the right way to do it? Is there a better alternative?

For e.g. I wrote the code below to convert Nervea to Nervä.

def diacritics(english_string):
   #replace english characters with german characters.
   english_string = english_string.replace("ae","ä")
   english_string = english_string.replace("oe", "ö")
   english_string = english_string.replace("ue", "ü")
   english_string = english_string.replace("Ae", "Ä")
   english_string = english_string.replace("Oe", "Ö")
   english_string = english_string.replace("Ue", "Ü")
   english_string = english_string.replace("ss", "ß")
   english_string = english_string.replace("SZ", "ß")

   return english_string
  • 4
    Parzival, have you checked the scope of the site? We don’t give programming advice, this is a site for language learners and speakers. Please take the tour and browse through our help center to learn more about how the site works. That said, no, your approach has a fundamental flaw: in German, especially in names, we have both ‘ae’ and ‘ä’, ‘oe’ and ‘ö’, etc. – Stephie May 30 '19 at 15:52
  • 1
    @Stephie I don't think it's completely out of scope. But yes, it's on the edge. As you said, one can see it as algorithm-proofreading, but also as "Is it always possible to convert ae, oe, etc. into Umlauts". Parzival probably should edit it :) . – mtwde May 30 '19 at 16:04
  • 4
    @mtwde which is why I didn’t VTC (others did already) and asked for clarification instead. In any case, this question needs an edit. – Stephie May 30 '19 at 16:06
  • 6
    This is only possible with a lookup table for every known word as there are words and names that do contain "ue" and the like. – idmean May 30 '19 at 16:09
  • 1
    @userunknown ist mir sehr wohl bewusst. In diesem Fall habe ich die Frage primär in dem Sinne verstanden, wie sie auch gemeint war (womit sie für mich nicht zu schließen war), ging aber davon aus, dass manche Leser sie als Programmierungsproblem verstehen können und habe deshalb den Frager angesprochen, was auch innerhalb kürzester Zeit funktioniert hat. Nur hatte ich keine Zeit mehr, die Frage zu editieren, sonst wären die Kommentare bereits gelöscht bzw als “no longer needed” geflaggt. Trotzdem danke für den Hinweis. – Stephie May 31 '19 at 3:46

Names may contain ae, oe, ue:

Baedeker [ɛː]
Goethe [øː]
Fuest* [uː]

Note that adjacent vowels may also belong to different syllables:

Michael [ˈmɪça.(ʔ)eːl]
Oboe [oˈboː.ə]
eventuell [evɛntʊˈɛl]

Therefore, no automatic translation from ae, oe, ue to ä, ö, ü is possible.

The graphemes ss, ß are used to distinguish the length of the preceding vowel. Therefore, one cannot be substituted for the other.

Maße [maːsə]
Masse [masə]

Also, there are many complex words where two adjacent s belong to different morphemes:

aus+sehen, weis+sagen, los+stürmen …

*Note that Fuest belongs to a group of names where e does not indicate umlaut but length of the preceding vowel.

| improve this answer | |
  • 2
    This could go into the "Michael" block: "Ausschalter" cannot be turned into "Außchalter" – Hagen von Eitzen May 30 '19 at 18:07
  • 1
    "Quelle"! would be non-proper noun where translation wouldn't work, and creates another category. – tofro May 30 '19 at 22:02
  • “Qübec” will annoy all Canadians. – gnasher729 May 31 '19 at 9:48
  • Was ist mit Nervä? – user unknown May 31 '19 at 12:50
  • "The graphemes ss, ß are used to distinguish the length of the preceding vowel. Therefore, one cannot be substituted for the other." - if ß is not available, replacing ß with ss is indeed the typical way to go. But I agree some information is lost in the process and the inverse substitution cannot be done purely by looking at the letters. – O. R. Mapper Jun 1 '19 at 10:56

Ich habe eine blaue Jacke und einen grauen Mantel. Ich sah zwei Pfauen im Park.

Lots of words contain these letter combinations and are bout umlauts.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.