title: How to set UWP language on runtime
body: <p>i'm currently developing a cross-platform App using Xamarin.Forms 3.4 and Visual Studio 2017 (latest version by now).</p>
  
  <p>Since that App should support multiple languages which can be changed on runtime, i'm currently looking into ways to get this done. I already added several resources and translated all interface elements which works just fine. I read through this article to get started:
  <a href="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/</a></p>
  
  <p>For now, when using the UWP app, the language is automatically set to my current system settings, which is the german language, even if the default app language is english. Thats fine.</p>
  
  <p>Now, I got a method which configures my current language by setting several information, like the default CultureInfo object. That method looks like follows:</p>
  
  <pre><code>    public void UpdateAppLanguage()
      {
        CultureInfo ci;
        Language l;
  
        // storage is a class containing several persistent information, like
        // the language selected by the user to be used
        // the Local attribute states if the language is actually present on
        // the current user's system
        if(Storage.GetCurrentLanguage().Local == true)
        {
          // language is present locally, so the user wants to use that one for
          // the interface
          ci = new CultureInfo(Storage.GetCurrentLanguage().Code);
          AppResources.Culture = ci;
          CultureInfo.CurrentCulture = ci;
          CultureInfo.CurrentUICulture = ci;
          CultureInfo.DefaultThreadCurrentCulture = ci;
          CultureInfo.DefaultThreadCurrentUICulture = ci;
          DependencyService.Get&lt;ILocalize&gt;().SetLocale(ci); // set the Thread for locale-aware methods
        }
        else
        {
          // no preferences available yet, use the system's current ci
          if (Device.RuntimePlatform != Device.UWP)
            ci = DependencyService.Get&lt;ILocalize&gt;().GetCurrentCultureInfo();
          else
            ci = CultureInfo.CurrentCulture;
  
          l = new Language{
            Name = ci.EnglishName,
            Code = ci.TwoLetterISOLanguageName
          };
  
          Storage.SetCurrentLanguage(l);
          CultureInfo.CurrentCulture = ci;
          CultureInfo.CurrentUICulture = ci;
          AppResources.Culture = ci; // set the RESX for resource localization
          DependencyService.Get&lt;ILocalize&gt;().SetLocale(ci); // set the Thread for locale-aware methods
       }
      }
  </code></pre>
  
  <p>I'm currently testing with a language set, and that language is English.</p>
  
  <p>And here is the dependency service implementation for the UWP sub-project:</p>
  
  <pre><code>  public class Localize : stereopoly.ILocalize
    {
      public void SetLocale (CultureInfo ci)
      {
        //Windows.Globalization.ApplicationSettings.PrimaryLanguageOverride = ci.Name;
        Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "EN-US";
        Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
        Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
      }
  
      public CultureInfo GetCurrentCultureInfo ()
      {
        return null;
      }
    }
  </code></pre>
  
  <p>As you can see, I also tried to set the language to EN-US by force, which doesn't work either. I'm calling the UpdateAppLanguage() method even before the initial Application.InitializeComponent() method runs, I also tried calling it within the OnStart() event method, neither works.</p>
  
  <p>I'd expect the language change getting applied since its executed even before the actual Application starts, but I can switch the several pages of my app as often as I want, the language will always be german, no matter what I do.
  I found several answers to this question for plain UWP apps, but not for Xamarin.Forms implementations of UWP projects and that seems to be the problem here, because no other hint regarding pure UWP apps seem to work.</p>
  
  <p>Do you have any idea what might help me?</p>
  
  <p>Thanks.</p>