This is a non-trivial task, e.g.
- 'Á' -> 'A' in Brazilian
- 'ö' -> 'oe' in German
- 'ẞ' -> 'Ss' in German normal text, -> 'SS' in German ALLCAPS*
- 'Ø' -> 'Oe' in Danish normal text, -> 'OE' in Danish ALLCAPS*
- 'ǿ' -> 'ø' -> 'oe' in Danish normal text, -> depending on previous letter 'Oe' or 'oE' in Danish aLtErNaTiNg CaSe*
etc. so the API would have to take as inputs
- source text
- language
- meta-information (likely more than I am aware from the examples above)
and output transliterated text.
As many languages have these constructs, I'd like to not list them all myself and wonder whether there is not some library out there that has done the job for me.
Partial answers encouraged - if e.g. an open-source library supported this for Brazilian but not for German, I'd still rather contribute the German mappings myself than write my own library from scratch.
Encoding is guaranteed to be UTF-16, conversion to other Unicode variants would not pain me either.
Note that pure unicode normalisation not only does not catch all forms of umlaut - e.g. not 'ß', 'ł', 'ø', only partially 'ǿ' - and it also cannot transliterate them language-appropriately. All it does is strip characters.
(I do not think there can be a purely algorithmic solution.)
* - Changing the case of some text is well enough encapsulated that doing this separately, outside the library, would be fine. That is (please correct me, if this is an i18n "popular-but-wrong" misconception of mine) one could always first transliterate, then apply case in two, strictly segregated steps.
I am only using this as an obvious example for how the correct transliteration may depend on other letters in the source.
Addendum: It occurs to me that writing any particular language binding ought to be mostly trivial, if only the dictionary existed in whatever sort of structured language. So, I'll also accept answers pointing to e.g. a Word Net or similar machine-processible collection, as long as it lists specifically these umlauts and the relevant rules for their transformation.
To that end I opened another question at Linguistics.
SøM ØxAmPlE
, which would becomeSoeM OExAmPlE
(all replacements in the same case, no longer alternating) orSoEm OeXaMpLe
(expected by me, each character alternating, but where the casing completely flips around).