Reputation: 2363
I am using the ResX approach for localized resources in a Xamarin Forms app, the Localizer class below, and three resource files (default en-us, es, ar).
When the Android device setting is language Spanish, the appropriate translated string is displayed, but when the device setting is Arabic, the default string is displayed. I have set the attribute android:supportsRtl:"true" in app manifest, and am targeting Android 4.2 or higher.
What am I missing?
public class Localizer
{
#region Constructors
public Localizer()
{
RefreshLocale();
this.Resources = new ResourceManager("MyApp.Resx.AppResources", typeof(Localizer).GetTypeInfo().Assembly);
}
#endregion Constructors
#region Methods
public void RefreshLocale()
{
this.Locale = DependencyService.Get<ILocale>().GetCurrent();
}
public string Localize(string key)
{
return this.Resources.GetString(key, new CultureInfo(this.Locale));
}
#endregion Methods
#region Properties
public string Locale { get; private set; }
private ResourceManager Resources;
#endregion Properties
}
Upvotes: 2
Views: 1333
Reputation: 2363
Oh duh, bitten again. The Build Action was set to None for the Arabic resource file AppResources.ar.resx. This appears to be default Xamarin Studio behavior when adding files with this filetype. Changed the Build Action to EmbeddedResource, rebuilt and deployed, and everything works as expected.
Upvotes: 1