Windows 8 Metro App (XAML) - How to set default startup language?

I am trying to set the default startup language in my Windows Metro app in App.xaml.cs, but I cannot find a place to do this. I usually install this using Thread.CurrentCulture in C #, but I cannot find the Thread namespace. Is there anything I am missing here?

+3


source to share


7 replies


This works fine on Windows8 CP:



Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "de";
var resourceLoader = new ResourceLoader();

      

+4


source


If it's still as requested, I have an option:

Try setting the default app language in Package.appxmanifest. Open the manifest with VS and set the default language in the appropriate field (app interface -> default language).



Hope it helps.

+1


source


You can try to install it on your project build. Try right-clicking the project, then Build Info ... and select culture neutral.

0


source


You can set the default thread culture using the CultureInfo.DefaultThreadCurrentCulture property.

0


source


Maybe setting it in App.xaml.cs like below will help

Windows.Globalization.ApplicationPreferences.PreferredLanguage = "no";

      

Where "no" is the BCP47 language tag for Norwegian.

Update : Change Metro App Language at Runtime

As per Windows 8 SDK Sample Resources and Application Localization

It is possible that the language, scale, contrast, or other settings may change while the application is running. To handle these events, event listeners must be registered to listen for and respond to the change. This can be done either by saving state and refreshing the page, or by redrawing certain resources.

Now in my language change select event I set PreferredLanguage as:

Windows.Globalization.ApplicationPreferences.PreferredLanguage = "en";
this.Frame.Navigate(this.GetType());

      

And the key thing I was missing is the code below in the App OnLaunched event:

ResourceManager.Current.DefaultContext.QualifierValues.MapChanged += async (s, m) => 
{
    if (m.Key == "Language")
    {
        // react to language change
    }
};

      

I did not place this event registration in the Page construtor or any page event (as in the SDK example) because then it could have been registered multiple times. However, this event must be logged somewhere when the language change takes effect at runtime.

0


source


I think what you are looking for (in CP) Windows.Globalization.ApplicationPreferences.PreferredLanguage.

Please note that your manifest must contain a list of all languages ​​you support. VS will automatically install languages ​​for you if the manifest in the project contains x-generate

.

0


source


Open the code view of your package Package.appxmanifest Change the resources to:

  <Resources>
    <Resource Language="x-generate" />
  </Resources>

      

0


source







All Articles