How can i find the language for a given locale?
Example: input: en_US output: English
Using the .NET libraries? I tried the CultureInfo class, but i can't find something usefull.
Thanks!
Do not use the constructor of CultureInfo
. It is faster to use the static GetCultureInfo
method since this method is cached and returns an immutable (readonly) CultureInfo
object.
According to the Facebook SDK documentation concerning localization, it is safe to assume that you can replace the underscore by a dash in order to allow .NET to understand the locale.
Facebook locales follow ISO language and country codes respectively, concatenated by an underscore.
The basic format is ''ll_CC'', where ''ll'' is a two-letter language code, and ''CC'' is a two-letter country code. For instance, 'en_US' represents US English.
Depending if you need the name to appear in english regardless of the language of the OS, use
CultureInfo.GetCultureInfo("en-US").EnglishName
If you need the name in the language of the OS, use:
CultureInfo.GetCultureInfo("en-US").DisplayName