ApplicationLanguages.PrimaryLanguageOverride | primaryLanguageOverride property

Applies to Windows and Windows Phone

Gets or sets an override for the app's preferred language, expressed as a BCP-47 language tag. This setting is persisted.

Syntax


public:
static property String^ PrimaryLanguageOverride { 
   String^ get();
   void set (String^ value);
}

Property value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

A BCP-47 language tag. The app can set it to override the top language of the user's ranked list of preferred languages (ApplicationLanguages.Languages), and its value will persist between app sessions. It must be a single language tag; a delimited list of language tags will fail.

When your app gets the value, PrimaryLanguageOverride returns either a single language tag (if your app has previously set the property) or an empty string.

Remarks

Apps normally run with language settings determined by the system by comparing the languages supported by the app with the language preferences of the user. The settings for that system behavior can be obtained using the ApplicationLanguages.Languages property. The PrimaryLanguageOverride property is used to override that behavior by setting a specific language as the first language in the Languages list.

The PrimaryLanguageOverride setting is persisted between sessions. It should not be set each time the app is loaded. It should only be set based on user input presented in settings UI. The property can be read at any time. If the property has never been set, it returns an empty string.

When you set the PrimaryLanguageOverride, this is immediately reflected in the ApplicationLanguages.Languages property. However, this change may not take effect immediately on resources loaded in the app UI. To make sure the app responds to such changes, you can listen to the QualifierValues property on a default resource context and take whatever actions may be needed to reload resources. Those requirements may vary depending on the UI framework used by the app, and it may be necessary to restart the app.

Note  If your app passes language tags from this class to any National Language Support functions, it must first convert the tags by calling ResolveLocaleName.

Starting in Windows 8.1:

Language tags can support Unicode extensions. See the Remarks for the ApplicationLanguages class.

Windows Store apps can be deployed using resource packages. When language resource packages are used, the packages that are installed and registered for a given user are determined by the languages in the user's language profile. As a result, not all of the languages included in the app bundle that was submitted to the Windows Store will necessarily be available for use at runtime. The PrimaryLanguageOverride property should only be set to languages that are available for the user.

The languages available for the app to use as an ApplicationLanguages object at runtime are limited to those languages included in the main app package manifest and the languages corresponding to language resource packages that are applicable for the user (determined by matching languages in the user's preferences), and that are installed and registered for the user. The ApplicationLanguages.ManifestLanguages property reflects language resource packs that are available for the user, and hence returns an appropriate set of languages that can be used for setting the PrimaryLanguageOverride property.

The ApplicationLanguages.Languages property will return a very similar list to the ManifestLanguages property. It may differ in including regional language variations not listed in any package manifest; for example, "en-CA" (English (Canada)) can be returned by the Languages property if the user has "en-CA" in their profile and the app supports any regional variety of English. Such user-derived regional language variations can be preferable for setting the PrimaryLanguageOverride property since the app will then provide globalization behaviors more appropriate for the user.

If a language is in the main app package but is not a match for any language in the user's preference, it is returned by the ManifestLanguages property but not the Languages property. These can also be used for setting the PrimaryLanguageOverride property. However, since these languages are not reflected in the user's preferences, the user might not understand those languages. Such settings should be used only when chosen directly by the user.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Globalization
Windows::Globalization [C++]

Metadata

Windows.winmd

See also

ApplicationLanguages
ApplicationLanguages.Languages
BCP-47 language tags

 

 

Show:
© 2014 Microsoft