Different English name of Czechia on my local machine vs on Azure

201 Views Asked by At

I'm trying to get RegionInfo object by the country name. I've come up with this code:

 var regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures).Select(x => new RegionInfo(x.LCID));
 var regionInfo = regions.FirstOrDefault(region => region.EnglishName.Contains(englishCountryName));

and it works fine on my machine. But when I deployed it on Azure App Service it returns null for Czechia.

So I tested it:

//My machine
new RegionInfo(1029).EnglishName //returns Czechia
//Azure
new RegionInfo(1029).EnglishName //returns Czech Republic

As it turned out, Czech Republic changed it's name in 2016 so why Azure displays "old" name? How to make this solution culture-independent?

1

There are 1 best solutions below

0
Fabo.sk On

With country name potentially changing, you are better off using one of the ISO codes.

If you cannot use ISO codes based on your input, you can take control of mapping English language input to ISO code using something like ISO3166 NuGet package. I see that the current version does not seem to be up to date either, but if you implement it, at least you will get a consistent value.