private static void addCustomCulture(CustomCulture culture) { CultureAndRegionInfoBuilder cib = null; try { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList(); var addCulture = true; foreach (CultureInfo info in cultures) { if (string.Compare(info.Name, culture.CultureName, true) == 0) { addCulture = false; break; } } if (addCulture) { Console.WriteLine("adding culture " + culture.CultureName); cib = new CultureAndRegionInfoBuilder(culture.CultureName, CultureAndRegionModifiers.None); cib.LoadDataFromCultureInfo(new CultureInfo(culture.BaseFrom)); cib.LoadDataFromRegionInfo(new RegionInfo(culture.BaseFromReg)); cib.CultureEnglishName = culture.EnglishName; cib.CultureNativeName = culture.NativeName; cib.IetfLanguageTag = culture.CultureLangTag; cib.RegionEnglishName = culture.RegEnglishName; cib.RegionNativeName = culture.RegNativeName; cib.Register(); System.Console.WriteLine(cib.CultureName + " => created"); } else { Console.WriteLine("already exists " + culture.CultureName); } } catch (Exception e) { System.Console.WriteLine(e.Message); } }
//Used to unregister a culture private static void removeCustomCulture(CustomCulture culture) { CultureAndRegionInfoBuilder.Unregister(culture.CultureName); }