// Resolve a culture name using a string culture. private static String GetCultureName(RootCulture info, RootCulture str) { String name = str.ResolveLanguage (info.TwoLetterISOLanguageName); String country = info.Country; if (country != null) { name = name + " (" + str.ResolveCountry(country) + ")"; } return(name); }
// Add currency information to a NumberFormatInfo object. public static void AddCurrencyInfo (NumberFormatInfo nfi, RootCulture culture) { String country = culture.Country; if (country != null) { RegionName region = GetNameInfoByName(country); if (region != null) { nfi.CurrencySymbol = region.currencySymbol; nfi.CurrencyDecimalDigits = region.currencyDigits; } } }
// Get the culture handler for the current culture. public static RootCulture GetCurrentCulture() { // Get the culture handler for the current culture. int cultureID = CultureInfo.CurrentCulture.LCID; StringBuilder builder = new StringBuilder(); builder.Append(hex[(cultureID >> 12) & 0x0F]); builder.Append(hex[(cultureID >> 8) & 0x0F]); builder.Append(hex[(cultureID >> 4) & 0x0F]); builder.Append(hex[cultureID & 0x0F]); String name = builder.ToString(); RootCulture culture = (PrimaryManager.Instantiate("CID" + name) as RootCulture); // Use invariant English if we couldn't find the culture. if (culture == null) { culture = new CNen(); } return(culture); }
// Add currency information to a NumberFormatInfo object. public static void AddCurrencyInfo (NumberFormatInfo nfi, RootCulture culture) { String country = culture.Country; if(country != null) { RegionName region = GetNameInfoByName(country); if(region != null) { nfi.CurrencySymbol = region.currencySymbol; nfi.CurrencyDecimalDigits = region.currencyDigits; } } }
// Get the native name for a particular culture. public static String GetNativeName(RootCulture info) { return(GetCultureName(info, info)); }
// Get the English name for a particular culture. public static String GetEnglishName(RootCulture info) { return(GetCultureName(info, new CNen())); }
// Get the display name for a particular culture. public static String GetDisplayName(RootCulture info) { return(GetCultureName(info, GetCurrentCulture())); }
// Get the native name for a particular culture. public static String GetNativeName(RootCulture info) { return GetCultureName(info, info); }
// Get the English name for a particular culture. public static String GetEnglishName(RootCulture info) { return GetCultureName(info, new CNen()); }
// Get the display name for a particular culture. public static String GetDisplayName(RootCulture info) { return GetCultureName(info, GetCurrentCulture()); }
// Resolve a culture name using a string culture. private static String GetCultureName(RootCulture info, RootCulture str) { String name = str.ResolveLanguage (info.TwoLetterISOLanguageName); String country = info.Country; if(country != null) { name = name + " (" + str.ResolveCountry(country) + ")"; } return name; }