简体   繁体   中英

Xamarin Forms Globalization

I have looked over this article regarding globalization in Xamarin Forms. The article indicates I need to create an interface in order to access the language on each platform. However, in my last App, I was able to simply put this line of code in my shared code and it seemed to work fine for getting the language:

ls_Language = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

Is there a reason a line of code similar to this wont work for Globalization using a resource file in Xamarin Forms?

Yes, your code is to set resource Culture when the application first loads, it is the same as using the DependencyService in the Xamarin.Forms App class to call the interface and set our RESX resources culture to the correct value.

You may optionally update this value according to platform-specific events that may be raised on iOS or Android if the user updates their language preferences while the app is running. So you need to use ILocalize interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM