1
votes

On Xamarin Forms Guides (http://developer.xamarin.com/guides/cross-platform/xamarin-forms/localization/) for localization we create the Resx and build the custom Localization class for each platform. That part is pretty simple and clear.

My question is, do i need to send in the application all the localized files or is there a way that when the user changes languages in my app i download the required Resx file from the server and apply the changes?

1

1 Answers

1
votes

I would have a look at this example: Xamarin Forms localization Xlf

in here there is a class that does the translation

  public static string Localize(string key)
  {
       try
       {
           var netLanguage = Locale();
           ResourceManager temp = new ResourceManager("MyApp.Strings.AppResources", typeof(Translator).GetTypeInfo().Assembly);
           string result = temp.GetString(key, new CultureInfo(netLanguage));

           return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

but here instead of using ResourceManagerto get your string you would get it from a Sqlite database which you would download the relevant translations for on startup of your app depending on the Locale of your application.

In xaml you would use this class like this:

<ContentPage xmlns:local="clr-namespace:MyApp;assembly=MyApp">
   <Label Text="{local:Translate MyFieldStrike}"/>
</ContentPage>

In answer to your original question I would say no there isn't a way to dynamically download and load your resource file as they are an embedded resource