Xamarin.Forms : How to use localization independent of device language

前端 未结 3 1145
有刺的猬
有刺的猬 2021-02-19 10:06

I am developing a Xamarin.Forms app (portable class library project) with Visual Studio 2013 CE. First I\'m focusing the iOS version.

Now I\'m thinking about how to make

3条回答
  •  忘了有多久
    2021-02-19 10:23

    Finally i got an answer of the Xamarin support. The solution i was thinking about works. In the PCL i just have the static Settings class which stores the different CultureInfo objects. In addition I defined a method for changing the current culture and the language of the resources file.

    public static void ChangeCurrentCultureInfo(CultureInfo cultureInfo)
    {
        CurrentCulture = cultureInfo;
        Resource.Culture = CurrentCulture;
    }
    

    It was important to set the default language in the App() constructor before I initialize the main page. Now i got a listview with all supported languages with one tapped event which calls the ChangeCurrentCultureInfo method.

    Nevertheless i want to thank Andy Hopper for providing his solution!

    Regards

提交回复
热议问题