Cross Platform localization best practices

Hi,

We are working on cross platform localization using .net approach(Resx file). We have found two ways of approaching the same.

Kindly suggest which is the best way to proceed on the same.

  1. Converting Resource.Resx file into Strings.xml file , Strings files to use in Android and iOS . (As mentioned in the below link)
    Codemag-Cross-Platform Localization for Mobile Apps.

  2. Using Resource.Resx file without converting into strings.xml and string files by using ResourceManager Class of .NET in Code Behind and binding the each control text from Resource File directly.

Sample Code:
[Activity(Label = "Sample.Android", MainLauncher = true, Icon = "@drawable/icon")] public class Activity1 : Activity { protected Adapters.NoteListAdapter noteList; private Button button = null; ResourceManager _manager ; protected override void OnCreate(Bundle bundle) { try { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); button = FindViewById<Button>(Resource.Id.MyButton); String CurrentLanguage = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; if (CurrentLanguage=="fr") _manager = new ResourceManager("Sample.Android.Resources.Resource1", typeof(Activity1).Assembly); else _manager = new ResourceManager("Sample.Android.Resources.Resource1", typeof(Activity1).Assembly); CultureInfo culturename = CultureInfo.GetCultureInfo(CurrentLanguage); button.Text = _manager.GetString("SampleText", culturename); } catch (Exception ex) {} } }

Sign In or Register to comment.