Skip to content

Language codes

This is the one that trips everyone up. Eurotext does not speak BCP-47. It has its own codes. Most are just lowercase BCP-47 (de-DEde-de), but a chunk of them aren't, and there's no rule you can derive them from — you have to look them up.

The always-correct source is GET /info/languages. LanguageMap covers the common locales so you don't have to hit the API for every conversion.

use Eurotext\LanguageMap;

LanguageMap::toEurotext('de-DE'); // 'de-de'
LanguageMap::toEurotext('mt-MT'); // 'mlt'   <- not "mt-mt"
LanguageMap::toEurotext('de-de'); // 'de-de' (already Eurotext form, passes through)
LanguageMap::toEurotext('xx-YY'); // throws InvalidArgumentException

The ones that bite

If you only remember a handful, remember that these are not lowercase BCP-47:

Locale Eurotext Locale Eurotext
mt-MT mlt ga-IE gai
da-DK da cs-CZ cz-cz
vi-VN vn id-ID ind
ms-MY msa hi-IN hin
is-IS ice cy-GB wel
ca-ES cat gl-ES glg
af-ZA afr sq-AL alb

Plenty of single-region languages also drop the region entirely: pl-PLpl, hu-HUhu, tr-TRtr, uk-UAuk, el-GRel, and so on.

Common ones that behave

These are exactly what you'd guess — lowercase the whole thing:

de-DEde-de, de-ATde-at, de-CHde-ch, en-GBen-gb, en-USen-us, fr-FRfr-fr, es-ESes-es, es-MXes-mx, it-ITit-it, nl-NLnl-nl, pt-PTpt-pt, pt-BRpt-br, ru-RUru-ru, zh-CNzh-cn, zh-TWzh-tw, ja-JPja, ko-KRko-kr.

The full mapping lives in src/LanguageMap.php. If you hit a locale it doesn't know, add it there (and pull the exact code from /info/languages).

When to trust the live list over the table

The table in LanguageMap is a convenience copy and can drift if Eurotext adds languages. If you're building anything that lets a user pick a target language, populate the dropdown from GET /info/languages at runtime rather than from the static table.