Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Localization

$
0
0

I'm using Xamarin Forms to deliver an app on Android and iOS that offers English and Arabic. That means I have resx files for strings, localized images assets and layout changes all contingent on the language. I have all of that working but have just one problem.

When app starts I set the locale the user has specified in their preferences. It's as early in the app as it can, using iOS as the example it's set in the Main function before even calling the AppDelegate. I've tried setting this at several stages but the result is always the same, it doesn't take affect until the app is closed and restarted. So I tried calling it before the app closes and that doesn't work. It's as if the app has to have it set during startup and then it has to reset.

To be clear the RESX files load okay. The part that doesn't work are the localized image assets and the layout changes. As a result I end up with Arabic text and English images or vice versa and everything is on the wrong side.

This is how I'm setting the locale at startup (in main, on iOS):

 CultureInfo ci = new CultureInfo(locale);
 CultureInfo.DefaultThreadCurrentUICulture = ci;

 UIApplication.Main (args, null, "AppDelegate");

In summary, how can I force Xamarin Forms to use the specified locale for localized assets and left-to-right / Right-to-left layout changes without at least two app restarts?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>