3
votes

I'm trying to research the theme, but still have not clear understanding whether the RESX-based localization possible in Xamarin.Android. In my personal tries I wasn't able to get any localized strings, but only the neutral culture strings.

I also can see posts like this one where noted that it should work Android:

This works fine for Android and windows phone.

But I also can see posts like that one where localization is not going to be working.

So my question is simple. How to build RESX-based localized application for Android in Xamarin?

1
@Jason, I'm currently migrating our WPF application on Android and it will be really sad, if I can reuse BL (including models and viewmodels), but not resxie.

1 Answers

4
votes

[Answering to my own question]

Well, first of all, yes, RESX-based localization in Xamarin.Android is possible and works as expected.

Second, I've lost a lot of time in tries to make it working just due to lack of attention to details. I've read the article Localizing Xamarin.Forms Apps with RESX Resource Files several times, but I was always omitting the section Troubleshooting. Exactly there was a key:

Doesn't work in DEBUG mode (Android only)

If the translated strings are working in your RELEASE Android builds but not while debugging, right-click on the Android Project and select Options > Build > Android Build and ensure that the Fast assembly deployment is NOT ticked. This option causes problems with loading resources and should not be used if you are testing localized apps.

Third, while trying to find some alternative ways of solving my problem, I found interesting the approach described in the article Generating Localized Resources in Mono for Android Using T4. In pair with the cool NuGet package from Daniel Cazzulino described in the article How to transform T4 templates on build without installing a Visual Studio SDK I was able to build a simple alternative for Android platform based on my RESX from WPF project.

Hope it can help somebody.