Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What cultures are supported by the CultureInfo class in .NET 3.5?

I need a list of cultures that are supported by .NET 3.5, regardless of the OS used. This seems to be quite a struggle to obtain, though I am not sure why!

Edit: Arghh, I was not aware that it is dependent on the OS, that would explain the lack of documentation. Any ideas on what is supported by Mac/Linux OS as well?

Thanks :)

like image 497
Fiona - myaccessible.website Avatar asked Feb 17 '10 16:02

Fiona - myaccessible.website


3 Answers

Unfortunately, it is OS dependent. Check here for default language support per OS.

Note, the CultureInfo documentation warns:

Windows versions or service packs can change the available cultures.

In ASP.NET, it's the browser that's important versus the OS. It can tell you which language the user prefers via the Accept-Language (Section 14.4) request header. If you set your app's globalization configuration to enableClientBasedCulture="true", ASP.NET will try to automatically set the UICulture and Culture to the value provided by the browser. Alternatively, you can set Culture manually by inspecting the Request.UserLanguages property:

  • How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization
  • Rick Strahl shows manual detection and setting

Unfortunately, there's no way to generate an exhaustive list of possible languages from an OS or browser. The closest thing is the IANA Language Subtag Registry. This is the language registry described in RFC 4646 - the document that defines .NET's CultureInfo tags.

Keep in mind, language tags in Request.UserLanguages are not guaranteed to be valid. You'll want to check them. HTTP 1.1 uses an older recommendation for language tags and there's nothing stopping someone from sending gibberish in the language header.

like image 62
Corbin March Avatar answered Nov 15 '22 11:11

Corbin March


National Language Support (NLS) API Reference lists locale information and allows you to select the OS.

Microsoft Locale Builder is a tool to create custom locales for Windows Vista and later.

Get a list of supported cultures, including custom ones, for the OS.

C# Example,

System.Globalization.CultureInfo[] cultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures);
like image 24
Doug Domeny Avatar answered Nov 15 '22 12:11

Doug Domeny


It is possible to create custom cultures, but the default class supports those cultures provided by the operating system you're running on. There is a reference of the cultures supported by default on MSDN

like image 1
Rowland Shaw Avatar answered Nov 15 '22 11:11

Rowland Shaw