Is there a platform agnostic language identifier in Delphi?

Is there a platform agnostic language identifier in Delphi?

i.e. a parallel to Windows.LANG_XXX, but which can be used across all platforms?

 

5 thoughts on “Is there a platform agnostic language identifier in Delphi?


  1. The closest thing I know is Firemonkey’s IFMXLocaleService, which provides GetCurrentLanguageID: string. The string returned is a two-letter string according to (one of) the ISO-639 standards.


    The Windows version uses GetLocaleInfo(GetDefaultUserLCID,  LOCALE_SISO639LANGNAME), or ‘en’ if that fails.


    The Android version uses the first two characters of Locale.getISO3Language.


    The iOS version uses the first two characters of NSLocale.currentLocale.objectForKey(NSLocaleLanguageCode).


    The MacOS version uses the first two characters of NSLocale.currentLocale.localeIdentifier


  2. Note that I say Language, not Locale, Jeroen Wiert Pluimers.


    Translation code can be simplified with the use of a reference int, instead of a reference string.


    Languages doesn’t change much, and if I need to add a new one, I’d prolly need to make code changes as I don’t do external language files.

Leave a Reply