Share via


Language Class

Definition

A class that provides information related to BCP-47 language tags such as the language name and the script.

public ref class Language sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.ILanguageFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [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 Language final
/// [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)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.ILanguageFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class Language final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.ILanguageFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[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 sealed class Language
[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)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.ILanguageFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class Language
function Language(languageTag)
Public NotInheritable Class Language
Inheritance
Object Platform::Object IInspectable Language
Attributes

Windows requirements

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

Examples

// Get the top user-preferred language and its display name.
var topUserLanguage = Windows.System.UserProfile.GlobalizationPreferences.Languages[0];
var language = new Windows.Globalization.Language(topUserLanguage);
var displayName = language.DisplayName;

Remarks

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

Initialize this class with a BCP-47 language tag. For example, to work with the best current user-preferred language, pass in the top value from Windows.System.UserProfile.GlobalizationPreferences:

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

Version history

Windows version SDK version Value added
1803 17134 LayoutDirection
2004 19041 AbbreviatedName
2004 19041 GetMuiCompatibleLanguageListFromLanguageTags

Constructors

Language(String)

Creates a Language object.

Properties

AbbreviatedName

Gets the three-letter abbreviation for a BCP-47 language tag. For example, "en-US" is converted to "eng".

CurrentInputMethodLanguageTag

Gets the BCP-47 language tag for the currently enabled keyboard layout or Input Method Editor (IME).

DisplayName

Gets a localized string that is suitable for display to the user for identifying the language.

LanguageTag

Gets the normalized BCP-47 language tag for this language.

LayoutDirection

Gets the content layout direction (for text and UI elements) most appropriate for a language.

NativeName

Gets the name of the language in the language itself.

Script

Gets the four-letter ISO 15924 script code of the language.

Methods

GetExtensionSubtags(String)

Retrieves a vector of extension subtags in the current language for the given extension identified by singleton.

GetMuiCompatibleLanguageListFromLanguageTags(IIterable<String>)

Retrieves a set of Multilingual User Interface (MUI) tags derived from one or more BCP-47 language tags.

IsWellFormed(String)

Determines whether a BCP-47 language tag is well-formed.

TrySetInputMethodLanguageTag(String)

Tries to set the normalized BCP-47 language tag of this language.

Applies to

See also