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, ILanguageExtensionSubtagspublic sealed class Language : ILanguage, ILanguageExtensionSubtagsPublic NotInheritable Class Language Implements ILanguage, ILanguageExtensionSubtags
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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.

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;

Constructors

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

Creates a Language object.

public Language(String languageTag)public Language(String languageTag)Public Sub New(languageTag As String)
Parameters
languageTag
System.String System.String System.String

A BCP-47 language tag. See Remarks.

Attributes
See Also

Properties

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
Value
string string string

The BCP-47 language tag.

Attributes
See Also

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
Value
string string string

The localized name of the language.

Attributes

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
Value
string string string

The normalized BCP-47 language tag.

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

Attributes
See Also

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
Value
string string string

The name of the language in the language itself.

Attributes

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
Value
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.

Attributes

Methods

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<string> GetExtensionSubtags(String singleton)public IVectorView<string> GetExtensionSubtags(String singleton)Public Function GetExtensionSubtags(singleton As String) As IVectorView( Of string )
Parameters
singleton
System.String System.String System.String

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

Returns

The list of extension subtags identified by singleton.

Attributes

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)

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

public static PlatForm::Boolean IsWellFormed(String languageTag)public static bool IsWellFormed(String languageTag)Public Static Function IsWellFormed(languageTag As String) As bool
Parameters
languageTag
System.String System.String System.String

A BCP-47 language tag.

Returns
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.

Attributes
See Also

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

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

public static PlatForm::Boolean TrySetInputMethodLanguageTag(String languageTag)public static bool TrySetInputMethodLanguageTag(String languageTag)Public Static Function TrySetInputMethodLanguageTag(languageTag As String) As bool
Parameters
languageTag
System.String System.String System.String

The normalized BCP-47 language tag.

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

Returns
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.

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

See Also