2

I need to convert some 2-letter (neutral) identifiers (like en for English) so something more friendly for user, like English.

Is there an Api that does that using Win32 ? So far I have found only LCID family of functions that doesn't help.

shift66
  • 11,760
  • 13
  • 50
  • 83
cprogrammer
  • 5,503
  • 3
  • 36
  • 56

2 Answers2

2

You're looking for IsValidLocaleName, GetLocaleInfoEx and LOCALE_SLANGUAGE / LOCALE_SLOCALIZEDLANGUAGENAME / LOCALE_SENGLISHLANGUAGENAME, which are defined in WinNls.h as:

#define LOCALE_SLOCALIZEDDISPLAYNAME  0x00000002   // localized name of locale, eg "German (Germany)" in UI language
#if (WINVER >= _WIN32_WINNT_VISTA)
#define LOCALE_SLOCALIZEDLANGUAGENAME 0x0000006f   // Language Display Name for a language, eg "German" in UI language
#endif //(WINVER >= _WIN32_WINNT_VISTA)
#define LOCALE_SENGLISHLANGUAGENAME   0x00001001   // English name of language, eg "German"
#define LOCALE_SNATIVELANGUAGENAME    0x00000004   // native name of language, eg "Deutsch"

(depending on OS version and your requirements).

Note: XP only uses LCID's

Rogue
  • 11,105
  • 5
  • 45
  • 71
MSalters
  • 173,980
  • 10
  • 155
  • 350
1

here is a table : http://www.lingoes.net/en/translator/langcode.htm copy paste it, put it into a map and there you go.

WeaselFox
  • 7,220
  • 8
  • 44
  • 75
  • thanks but mapping should be my last option. Must be some Api that already does that. And second: there may be some (minor) differences: like: traditional Chinese (zh-Hant) and simplified Chinese (zh-Hans) vs zh-CN, zh-HK, zh-MO ... – cprogrammer Feb 13 '12 at 14:37