I have a web application in which I set the CultureInfo
on Thread.CurrentThread
to ar-IL
(Arabic-Israel):
Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-IL")
The problem is that on my local machine (Windows 10 with IIS 10) it works just fine and no exception is being thrown. However, on Azure (Windows Server 2012 R2 with IIS 8.5) it throws CultureNotFoundException
:
Culture is not supported. Parameter name: name 'ar-IL' is an invalid culture identifier
I checked the source of CultureInfo
and realized that the native call to nativeInitCultureData()
is the culprit. On my Windows 10 machine it returns true
but on Windows Server 2012 it returns false
.
Also, checking the SSCLI for nlsinfo.cpp
file reveals this comment:
// Call GetLocaleInfoEx and see if the OS knows about it. // Note that GetLocaleInfoEx has variations: // * Pre-Vista it fails and has to go downlevel // * Vista succeeds, but not for neutrals // * Win7 succeeds for all locales. // * Mac does ???
So, how can I handle custom combinations of languages and regions (ar-IL
, he-US
etc) that are not recognized by Windows?
P.S I'm aware of the possibility to create and register a custom locale (using CultureAndRegionInfoBuilder
) but it will take too much effort to cater for all the combinations I'm planning to support.