Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run Transliterator with DOTNET_SYSTEM_GLOBALIZATION_INVARIANT="1" #66

Open
gnattu opened this issue Mar 26, 2024 · 1 comment

Comments

@gnattu
Copy link

gnattu commented Mar 26, 2024

System.InvalidOperationException: Failed to compare two elements in the array.
 ---> System.TypeInitializationException: The type initializer for 'ICU4N.Text.Transliterator' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'ICU4N.Globalization.UCultureInfo' threw an exception.
 ---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en is an invalid culture identifier.
   at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
   at ICU4N.Globalization.UCultureInfo..cctor()
   --- End of inner exception stack trace ---
   at ICU4N.Globalization.UCultureInfo.get_CurrentCulture()
   at ICU4N.Impl.ICUResourceBundle.GetBundleInstance(String baseName, String localeID, Assembly root, OpenType openType)
   at ICU4N.Impl.ICUResourceBundle.GetBundleInstance(String baseName, String localeID, Assembly root, Boolean disableFallback)
   at ICU4N.Util.UResourceBundle.<>c__DisplayClass25_0.<GetRootType>b__0(String key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at ICU4N.Util.UResourceBundle.GetRootType(String baseName, Assembly root)
   at ICU4N.Util.UResourceBundle.InstantiateBundle(String baseName, String localeName, Assembly root, Boolean disableFallback)
   at ICU4N.Util.UResourceBundle.GetBundleInstance(String baseName, String localeName, Assembly root, Boolean disableFallback)
   at ICU4N.Util.UResourceBundle.GetBundleInstance(String baseName, String localeName, Assembly root)
   at ICU4N.Text.Transliterator..cctor()
   --- End of inner exception stack trace ---
   at ICU4N.Text.Transliterator.GetInstance(String id)

To my understanding, the transliterator should use its own culture data and run with Invariant mode?

Or am I wrong and this has to run with the culture data installed?

@NightOwl888
Copy link
Owner

Currently invariant globalization is one of many gaps to work out and as such, it is not directly supported. So, I will consider this a request to add support.

By default, UCultureInfo tracks the CultureInfo on the current thread. You can generally override this behavior by setting the UCultureInfo.CurrentCulture property directly to the culture you want to use, in which case you may be able to use the localized transliterator.

I say may because there are several places in the code where culture is round-tripped between UCultureInfo and CultureInfo, in which case it will automatically try to set the CultureInfo.CurrentCulture. However, UCultureInfo in most cases will supersede CultureInfo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants