Search code examples
androidxamlxamarinlocalization

Xamarin android App - Changing device language to "he-IL" does not set UICulture


I have a Xamarin forms (v5.0.0.1558pre3) android Application on Visual Studio 2019 I want my App to support different languages so I did the following:

  1. I have created AppResources.resx for default language resources and AppResources.he-IL.resx with just a resx file for my Hebrew language like so:

enter image description here

  1. I have set the language on the device to Hebrew.

  2. I then set all strings to use the resources:

    Text="{x:Static resources:AppResources.MonthlyUsage}"

When I launch the application, it still loads the default AppResources.resx values.

enter image description here

Other languages (like fr-FR) are being set just fine.


Solution

  • I think on Android you will need to check the currently set Android locale like so:

    var locale = Java.Util.Locale.Default;
    

    There is a thread on the Xamarin Forums describing a similar issue: https://forums.xamarin.com/discussion/74484/app-crashes-when-language-set-to-hebrew

    It seems like you will also have to replace _ with - and also seems like iw_IL needs to be changed to he_IL.

    You will have to detect this on startup and adjust the CurrentUICulture accordingly.