creating custom CultureInfo for country, language combination

后端 未结 3 1857
日久生厌
日久生厌 2020-12-06 11:10

I am working on a .net 4.5 application that needs to be mult lingual supporting multi cultures etc.

The following is sample list of Countries/Languages

相关标签:
3条回答
  • 2020-12-06 11:51

    You should use CultureInfo.InvariantCulture Property

    The invariant culture is culture-insensitive; it is associated with the English language but not with any country/region. You specify the invariant culture by name by using an empty string ("") in the call to a CultureInfo instantiation method. CultureInfo.InvariantCulture also retrieves an instance of the invariant culture. It can be used in almost any method in the System.Globalization namespace that requires a culture. The objects returned by properties such as CompareInfo, DateTimeFormat, and NumberFormat also reflect the string comparison and formatting conventions of the invariant culture.

    CultureInfo.InvariantCulture Property

    This is other option Custom Global Application Culture

    0 讨论(0)
  • 2020-12-06 12:01

    Is it possbile to create custom CultureInfo objects for invalid culture name

    Yes.

    Make use of CultureAndRegionInfoBuilder to help create the custom CultureInfo. (NB. once you have code to create a culture, the settings to do this can be saved to XML and then loaded, eg. from a resource, which should need less code at runtime.)

    An example project how to do that, plus downloadable code, can be found at CodeProject. An important note from the article is that, even though this class sits in the System.Globalization namespace, it is not available by default, quote:

    We’ll start by referencing the assembly sysglobl.dll and add a using statement for the namespace System.Globalization.

    0 讨论(0)
  • 2020-12-06 12:03

    You may have to mix and mix and match - have a culture object for English which you use for English text but a culture object of ru-Ru (Russian) for numeric formatting.

    Or even better create a custom culture combining the two

    Create custom culture in ASP.NET

    0 讨论(0)
提交回复
热议问题