How To Get the English Language Name For A Culture
Here’s a quick way to get the English name of a culture’s language.
var cultureInfo = CultureInfo.GetCultureInfo("ar-sa");
while (!cultureInfo.IsNeutralCulture)
{
cultureInfo = cultureInfo.Parent;
}
cultureInfo.EnglishName;
I’m checking the IsNeutralCulture
property to determine whether the culture is country dependant or not. For example, not doing this check would yield Arabic (Saudi Arabia)
which is not what I’m after here.
To retrieve the localised name for the language instead use cultureInfo.DisplayName
. This will give the language name based upon the locale of the SDK being used.
Comments
Post a Comment