Language Language Language Language Class

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

Syntax

Declaration

public sealed class Languagepublic sealed class LanguagePublic NotInheritable Class Language

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 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 summary

Creates a Language object.

Properties summary

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

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

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

Gets the name of the language in the language itself.

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

Methods summary

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

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

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

Constructors

  • Language(System.String)
    Language(System.String)
    Language(System.String)
    Language(System.String)

    Creates a Language object.

    public Language(System.String languageTag)public Language(System.String languageTag)Public Function Language(languageTag As System.String) As

    Parameters

    • languageTag
      System.String
      System.String
      System.String
      System.String

      A BCP-47 language tag. See Remarks.

Properties

  • CurrentInputMethodLanguageTag
    CurrentInputMethodLanguageTag
    CurrentInputMethodLanguageTag
    CurrentInputMethodLanguageTag

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

    public static string CurrentInputMethodLanguageTag { get; }public static string CurrentInputMethodLanguageTag { get; }Public Static ReadOnly Property CurrentInputMethodLanguageTag As string

    Property Value

    • string
      string
      string
      string

      The BCP-47 language tag.

  • DisplayName
    DisplayName
    DisplayName
    DisplayName

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

    public string DisplayName { get; }public string DisplayName { get; }Public ReadOnly Property DisplayName As string

    Property Value

    • 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 string LanguageTag { get; }public string LanguageTag { get; }Public ReadOnly Property LanguageTag As string

    Property Value

    • string
      string
      string
      string

      The normalized BCP-47 language tag.

      Starting in : Language tags can support Unicode extensions. See the Remarks for the @Windows.Globalization.Language.#ctor(System.String) constructor.

  • NativeName
    NativeName
    NativeName
    NativeName

    Gets the name of the language in the language itself.

    public string NativeName { get; }public string NativeName { get; }Public ReadOnly Property NativeName As string

    Property Value

    • 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 string Script { get; }public string Script { get; }Public ReadOnly Property Script As string

    Property Value

    • string
      string
      string
      string

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

Methods

  • GetExtensionSubtags(System.String)
    GetExtensionSubtags(System.String)
    GetExtensionSubtags(System.String)
    GetExtensionSubtags(System.String)

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

    public IVectorView<string> GetExtensionSubtags(System.String singleton)public IVectorView<string> GetExtensionSubtags(System.String singleton)Public Function GetExtensionSubtags(singleton As System.String) As IVectorView( Of string )

    Parameters

    Returns

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

  • IsWellFormed(System.String)
    IsWellFormed(System.String)
    IsWellFormed(System.String)
    IsWellFormed(System.String)

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

    public static bool IsWellFormed(System.String languageTag)public static bool IsWellFormed(System.String languageTag)Public Static Function IsWellFormed(languageTag As System.String) As bool

    Parameters

    • languageTag
      System.String
      System.String
      System.String
      System.String

      A BCP-47 language tag.

    Returns

    • bool
      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.

  • TrySetInputMethodLanguageTag(System.String)
    TrySetInputMethodLanguageTag(System.String)
    TrySetInputMethodLanguageTag(System.String)
    TrySetInputMethodLanguageTag(System.String)

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

    public static bool TrySetInputMethodLanguageTag(System.String languageTag)public static bool TrySetInputMethodLanguageTag(System.String languageTag)Public Static Function TrySetInputMethodLanguageTag(languageTag As System.String) As bool

    Parameters

    • languageTag
      System.String
      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 @Windows.Globalization.Language.#ctor(System.String) constructor.

    Returns

    • bool
      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

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.Globalization.dll