Unplanned
Last Updated: 10 Dec 2020 15:58 by ADMIN
Kori
Created on: 08 Dec 2020 16:15
Category: UI for Xamarin
Type: Bug Report
1
TelerikLocalizationManager sets the CurrentThread.CurrentCulture to the target device culture

Currently TelerikLocalizationManager sets CurrentThread.CurrentCulture on Android and iOS taking into account the target device culture.

If the developer has set the CurrentCulture on app level (different than the device culture), it is reset by our LocalizationManager.
1 comment
ADMIN
Yana
Posted on: 10 Dec 2020 15:58

You can workaround this issue by overriding the method that resets the culture on iOS and Android.

Go to AppDelegate.cs inside the iOS project and add an EmptyLocalize class which implements our ILocalize interface and basically overrides the default logic for resetting the culture:

public class EmptyLocalize : ILocalize
{
    public CultureInfo GetCurrentCultureInfo()
    {
        return CultureInfo.DefaultThreadCurrentUICulture;
    }

    public void SetLocale(CultureInfo cultureInfo)
    {
    }
}

ILocalize is from the Telerik.XamarinForms.Common namespace.

Register the EmptyLocalize class above the namespace:

[assembly: Xamarin.Forms.Dependency(typeof(MyXamarinApp.iOS.EmptyLocalize))]

The workaround can be applied on Android as well  - add the same EmptyLocalize inside the MainActivity.cs and register it in a similar way:

[assembly: Xamarin.Forms.Dependency(typeof(MyXamarinApp.Droid.EmptyLocalize))]

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.