Localization for mobile cross platform using xamarin and issue with iOS only

后端 未结 3 1243
栀梦
栀梦 2021-02-05 12:41

I have a project in Xamarin which targets Android, iOS and windows phone. I used core (PCL library) to share common code between different platform. I added Resource files (.net

相关标签:
3条回答
  • 2021-02-05 13:22

    For localization on our Xamarin projects I've used the Multilingual App Toolkit (detailed here) from Microsoft and T4 templates to transform the output from the toolkit to useable formats for Android and iOS.

    This tutorial has a fantastic overview of the process and it's based on this code project.

    0 讨论(0)
  • 2021-02-05 13:22

    Either:

    • You're not actually setting the CurrentCulture on iOS.
    • You're setting the CurrentCulture on thread A, and retrieving it on thread B.

    Try this:

    public string GetString() 
    {
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("nl-NL");
        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("nl-NL");
    
        // CommonResources is the name of my resource file   
        ResourceManager resManager = new ResourceManager(typeof(CommonResources));   
        return resManager.GetString("LoginLabel",CultureInfo.CurrentCulture); 
    }
    
    0 讨论(0)
  • 2021-02-05 13:25

    Do you test it on a real device? In the simulator it is not possible to change the culture. I had a similar issue with my language files.

    0 讨论(0)
提交回复
热议问题