0
votes

I'm going crazy for hours on an evil problem!!!

I've created a new Xamain Forms prj on Visual Studio for Mac (last version and last update).

I have three AppResources files for corrispondent languages: - AppResources.resx (for default) - AppResources.it.resx (for italian) - AppResources.es.resx (for spanish)

On IOS simulator, works all good. On Android I see always the default string.

This is my simple data on AppResources file:

AppResources.resx:
    <data name="test" xml:space="preserve">
        <value>Default</value>
    </data>

AppResources.es.resx:
        <data name="test" xml:space="preserve">
                <value>Espanol</value>
        </data>

AppResources.it.resx:
    <data name="test" xml:space="preserve">
            <value>Italiano</value>
    </data>

Why on IOS works perfectly and on Android I can see only "default"?!?

2
Have you followed this guide in order to make sure that everything is properly configured? docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/…. I have recently started a project with 6 languages in VS Mac and it works fine in iOS and Android. How do you initialise and update the culture you are using? - xerx
ummm this could be the problem....!!! "How do you initialise and update the culture you are using?" What do you mean? - Blasco73
But the code works on ios without any issue... why on android not? - Blasco73
On Android, the language settings are detected and cached when the application starts. If you change languages, you may need to exit and restart the application to see the changes applied.Check the tutorial:docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/… - Jarvan Zhang - MSFT
No... should be more easy, because I don't want to change language "live", I would like to see my application, at start, with correct language resources!!! But works only with IOS! - Blasco73

2 Answers

2
votes

The problem started for me after the last visual studio (MAC) update (Version 8.6 (build 4520))

Look this:

https://github.com/xamarin/xamarin-android/issues/4664#issuecomment-632986668

This workaround solved my problem.

0
votes

As a response to your comment above you could have a LocalizationService in which you will set and update your current culture (CultureInfo object). You can also use the static CultureInfo.InstalledUICulture to get the device culture.

    public CultureInfo CurrentCulture
    {
        get => cultureInfo;
        set
        {
            if(cultureInfo?.Equals(value) ?? false)
            {
                return;
            }
            cultureInfo = value;
            Thread.CurrentThread.CurrentCulture = value;
            Thread.CurrentThread.CurrentUICulture = value;
        }
    }