-
Notifications
You must be signed in to change notification settings - Fork 9
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
Use CultureInfo.CurrentUICulture instead of ResourceLanguage resource? #3
Comments
Thanks a lot for your feedback! The underscore was a mistake, I will change the documentation. For CultureInfo.CurrentUICulture, there is an issue. If you use the french version of Windows 10 for example and you launch an application only available in english, CultureInfo.CurrentUICulture will be equal to fr_fr instead of en_us. To summarize, CultureInfo.CurrentUICulture is the culture used by Windows, not by your app. |
Sorry, but
I do agree that it might not always represent the language that the app is being displayed in, though. I just can remember in which cases. My current test setup is a fr-FR OS with a en-GB language pack and the following language preferences (in order): fr-CH, qps-ploc, en-GB, es-CR. My app has the following resources: en-US (default), es, qps-ploc. When I run the app, So, on Windows 10 I can guarantee that using |
You missed something, try to create an app with default language set to "pt-BR" (appxmanifest) for example, CultureUI will be fr-CH in your case. As I said, CultureUI is related to Windows, it can only one of the value of your preference: fr-CH, qps-ploc, en-GB, es-CR, nothing else. If the app doesn't include one of them (or similar, fr-CH can be replaced by fr-FR is nothing is found), CultureUI will have an incorrect value.
|
Hmm... Still can't reproduce... On Win 10 (1607), even an app with pt-BR as it's default language and only resources will still give me pt-BR as the |
You were right, this behavior is only with SL8. An other reason I did it is due to the closest-match system used by Windows when a specific culture is not present: for example, if you PC is en-GB, Windows can use "en-US" if "en-GB" and "en" are not present. Because SL8 is (unofficially) deprecated and the closest match is not a real issue in fact for us (cause PluralNet uses only the two letters id, an no more the full name (it was the case of the proto), I will change the code to use CultureUI if ResourceLanguage is not set! Thanks for your feedback |
In the
README
file, it says that the resource files need to have aResourceLanguage
key in order to identify the language that is being used. It gives as an examplefr_FR
. TheResourceLoaderExtension
class then takes that value and creates aCultureInfo
instance.It appears, however, that the
CultureInfo
class is unable to parse cultures that use the underscore as a language/locale separator. I guess that theREADME
file should be updated to use a hyphen and/or the class could make the replacement at runtime to support both syntaxes.Then again, is using the
ResourceLanguage
key really necessary? I ran a test on a UWP app on Windows 10 (didn't run any other combinations) andCultureInfo.CurrentUICulture
is consistently providing the expected value. This makes sense, given that this is supposed to be theCultureInfo
instance used by the resource manager to look up culture-specific resources.If anyone's interested in testing on other platforms, I can create a PR.
The text was updated successfully, but these errors were encountered: