Search code examples
phplocaleintl

Why is PHP intl v.1.1.0 returning "El Salvador" for "-SV"?


I was going through the documentation, checking iso 2 digit country codes but I can't wrap my head around this. Everyone in the documentation it says that the 2 digit country code for Sweden is SV, yet it gives "El Salvador" back, when using this function

\Locale::getDisplayRegion('-SV', 'en')

According to this site (and other sites as well), El Salvador should be "es-SV" and Sweden should be "SV" or "sv-SE". Let's say SV doesn't exist at all in the \Locale "db", but then why would it return El Salvador (which is "es-SV") and not Sweden (which is "sv-SE").

To be fair, it does return Sweden for "es-SV", but I think it's confusing.

Does anybody have a clue why is this happening?


Solution

  • I think you are confusing the ISO 3166-1 alpha-2 country code of Sweden (SE) with the ISO 639-1 language code of Swedish (SV).

    The country code SV is indeed El-Salvador.

    In the country locale sv-SE, the sv part means the language code (Swedish), and the SE part means the country code (Sweden), mostly distinguishing it from sv-FI, which is the variant of Swedish spoken/written in Finland (FI).