Language Language Language Language Class

Definition

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

public : sealed class Language : ILanguage, ILanguageExtensionSubtags
public sealed class Language : ILanguage, ILanguageExtensionSubtags
Public NotInheritable Class Language Implements ILanguage, ILanguageExtensionSubtags
var language = new language(languageTag);
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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;
// 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:

Starting in : 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.

Constructors

Language(String) Language(String) Language(String) Language(String)

Creates a Language object.

public : Language(Platform::String languageTag)
public Language(String languageTag)
Public Sub New(languageTag As String)
var language = new language(languageTag);
Parameters
languageTag
Platform::String String String String

A BCP-47 language tag. See Remarks.

See Also

Properties

CurrentInputMethodLanguageTag CurrentInputMethodLanguageTag CurrentInputMethodLanguageTag CurrentInputMethodLanguageTag

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

public : static Platform::String CurrentInputMethodLanguageTag { get; }
public static string CurrentInputMethodLanguageTag { get; }
Public Static ReadOnly Property CurrentInputMethodLanguageTag As string
var string = Windows.Globalization.Language.currentInputMethodLanguageTag;
Value
Platform::String string string string

The BCP-47 language tag.

See Also

DisplayName DisplayName DisplayName DisplayName

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

public : Platform::String DisplayName { get; }
public string DisplayName { get; }
Public ReadOnly Property DisplayName As string
var string = language.displayName;
Value
Platform::String string string string

The localized name of the language.

LanguageTag LanguageTag LanguageTag LanguageTag

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

public : Platform::String LanguageTag { get; }
public string LanguageTag { get; }
Public ReadOnly Property LanguageTag As string
var string = language.languageTag;
Value
Platform::String string string string

The normalized BCP-47 language tag.

Starting in : Language tags can support Unicode extensions. See the Remarks for the Language constructor.

See Also

NativeName NativeName NativeName NativeName

Gets the name of the language in the language itself.

public : Platform::String NativeName { get; }
public string NativeName { get; }
Public ReadOnly Property NativeName As string
var string = language.nativeName;
Value
Platform::String string string string

The name of the language in the language itself.

Script Script Script Script

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

public : Platform::String Script { get; }
public string Script { get; }
Public ReadOnly Property Script As string
var string = language.script;
Value
Platform::String string string string

A string with the script code of the language. If the script code cannot be identified or inferred from the language tag, "Zyyy" is returned.

Methods

GetExtensionSubtags(String) GetExtensionSubtags(String) GetExtensionSubtags(String) GetExtensionSubtags(String)

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

public : IVectorView<Platform::String> GetExtensionSubtags(Platform::String singleton)
public IReadOnlyList<string> GetExtensionSubtags(String singleton)
Public Function GetExtensionSubtags(singleton As String) As IReadOnlyList<string>( Of string )
var iVectorView = language.getExtensionSubtags(singleton);
Parameters
singleton
Platform::String String String String

A single-character subtag for the LanguageTag of the current language. See BCP-47 language tags, Extensions and the Extensions Registry.

Returns
IVectorView<Platform::String> IReadOnlyList<string> IReadOnlyList<string> IReadOnlyList<string>

The list of extension subtags identified by singleton.

Remarks

If singleton does not exist for the current language, the returned vector is empty.

If singleton is a known system (such as "u", the Unicode extension), the returned subtags may be combined into logical units. For example, "de-DE-u-attr-co-phonebk" returns a vector with two items: "attr" and "co-phonebk". If singleton is unknown, each subtag is returned in a separate item.

See Also

IsWellFormed(String) IsWellFormed(String) IsWellFormed(String) IsWellFormed(String)

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

public : static Platform::Boolean IsWellFormed(Platform::String languageTag)
public static bool IsWellFormed(String languageTag)
Public Static Function IsWellFormed(languageTag As String) As bool
var bool = Windows.Globalization.Language.isWellFormed(languageTag);
Parameters
languageTag
Platform::String String String String

A BCP-47 language tag.

Returns
Platform::Boolean bool bool bool

True if the language tag is well-formed as defined by BCP-47, except when the language tag can never be valid according to BCP-47. Otherwise it returns false. If this method returns true, an application can safely construct a language by using this tag. If it returns false, attempting to construct a language for the given tag will throw an exception.

See Also

TrySetInputMethodLanguageTag(String) TrySetInputMethodLanguageTag(String) TrySetInputMethodLanguageTag(String) TrySetInputMethodLanguageTag(String)

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

public : static Platform::Boolean TrySetInputMethodLanguageTag(Platform::String languageTag)
public static bool TrySetInputMethodLanguageTag(String languageTag)
Public Static Function TrySetInputMethodLanguageTag(languageTag As String) As bool
var bool = Windows.Globalization.Language.trySetInputMethodLanguageTag(languageTag);
Parameters
languageTag
Platform::String String String String

The normalized BCP-47 language tag.

Starting in : Language tags can support Unicode extensions. See the Remarks for the Language constructor.

Returns
Platform::Boolean bool bool bool

true if the value is successfully set, otherwise false.

This method will only attempt to change the input language if the application is running on an IoT device. On non-IoT devices, the return value is always false.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)
Capabilities
systemManagement

See Also