Delen via


ApplicationLanguages Class

Definition

Specifies the language-related preferences that the app can use and maintain.

public ref class ApplicationLanguages abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ApplicationLanguages final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class ApplicationLanguages
Public Class ApplicationLanguages
Inheritance
Object Platform::Object IInspectable ApplicationLanguages
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

The languages referenced in this class are represented by BCP-47 language tags. Each of these is a language identifier and not a locale name, although the two structurally can be the same. As a language tag, "en-US" means American English (or the dialect of English spoken in the United States). It makes no claims about the actual location of the speakers (though many of them do reside in the US) and no other claims about conventions that are used in the US such as the measurement system or currency.

Example:

Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US"

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.

Language tags support the Unicode extensions "ca-" and "nu-". (See Unicode Key/Type Definitions.) Note that these extensions can affect the numeral system or calendar used by globalization objects.

UWP 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 Microsoft 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 packages that are available for the user, and 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.

Version history

Windows version SDK version Value added
1803 17134 GetLanguagesForUser

Properties

Languages

Gets a ranked list of current runtime language values preferred by the user.

ManifestLanguages

Gets the app's declared list of supported languages.

PrimaryLanguageOverride

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

Methods

GetLanguagesForUser(User)

Retrieves the language preferences of the specified user. This API is part of support for multi-user apps (MUA).

Applies to

See also