In my application I already am using a lot of culture codes, like de-DE, es-ES, cz-CZ etc. All languages work correct. However, I get an error with the culture coe Lt-sr-SP (Serbian, Latin).

When I call:

var culture = new CultureInfo(Settings.Default.UI_Language);

where Settings.Default.UI_Language = "Lt-sr-SP" I get an error that the culture is unsupported, the culture code is an invalid culture code identification (in Dutch so I cannot really copy it here without making sense for most of you).

For all used language I have a dedicated string resource file, but I even checked with a language I don't have such a resource file made for, and I don't get the error in such case.

有帮助吗?

解决方案

If you search the available cultures using the following code, you will find that the code you're looking for isn't in the set of available cultures.

var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.Name.Equals("Lt-sr-SP"));

If you search using

var culture = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.EnglishName.Contains("Serbian"));

You can see that the culture code you're looking for is sr-Latn-RS.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top