I am having an issue when I create new cultures for the use of translations. The current issue I have is that windows does not allow the app to access a folder where this cultures seem to be. In our local machine we can just put Visual Studio as admin and then we have no issues with this but since we deploy our app with Azure I would not know how to allow access to the folder that is having issues so we are getting this exception: System.Globalization.CultureNotFoundException: Culture is not supported. Parameter name: name en-US-biz is an invalid culture identifier.
Exception in the next part of code when we update the user Language:
var currentUserLanguage = 'en-US-biz';
IocContainer.SetCurrentUserLanguage(currentUserLanguage);
var ci = domCultureLanguage != null ? domCultureLanguage.CultureInfo : new CultureInfo(currentUserLanguage);
Thread.CurrentThread.CurrentUICulture = ci;
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);
inthe line: new CultureInfo(currentUserLanguage) is where I get the Exception.
We register the culture in the global.asax file:
private void LoadCultureManager()
{
BizCultureEn.Register();
BizCultureEs.Register();
}
And we have built 2 different culture classes + the rsex respective files.
Eg of BizCultureEn Class:
public static class BizCultureEn
{
//"es-ES-custom" need to match with Translations.es-ES-custom.resx
public static string CustomCultureName = "en-US-biz";
public static CultureInfo CultureInfo { get; set; }
public static void Register()
{
// Create a custom culture for ru-US.
CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder(CustomCultureName, CultureAndRegionModifiers.None);
CultureInfo = CultureInfo.CreateSpecificCulture(CustomCultureName);
builder.LoadDataFromCultureInfo(CultureInfo);
builder.CultureEnglishName = "Biz English (United States)";
builder.CultureNativeName = "Biz English (United States)";
builder.ThreeLetterISOLanguageName = "ben";
builder.ThreeLetterWindowsLanguageName = "ben";
builder.TwoLetterISOLanguageName = "bn";
builder.RegionEnglishName = "Biz English";
builder.ThreeLetterISORegionName = "USA";
builder.ThreeLetterWindowsRegionName = "USA";
builder.TwoLetterISORegionName = "US";
// Register the culture.
try
{
builder.Register();
}
catch (InvalidOperationException ex)
{
var ex1 = ex;
// Swallow the exception: the culture already is registered.
}
// Use the custom culture.
//CultureInfo = CultureInfo.CreateSpecificCulture(CustomCultureName);
Thread.CurrentThread.CurrentCulture = CultureInfo;
Thread.CurrentThread.CurrentUICulture = CultureInfo;
}
}