Language 類別

定義

類別,提供 與 BCP-47 語言標記相關的資訊,例如語言名稱和腳本。

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
繼承
Object Platform::Object IInspectable Language
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

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

備註

如果您的 app 會將此類別中使用的語言標籤傳遞給任何 國家語言支援 函式,則必須先呼叫 ResolveLocaleName來轉換標籤。

使用 BCP-47 語言標籤初始化這個類別。 例如,若要使用最佳的目前使用者慣用語言,請從 Windows.System.UserProfile.GlobalizationPreferences傳入最上方的值:

語言標籤支援 Unicode 延伸模組 「ca-」 和 「nu-」。 (請參閱 Unicode 索引鍵/類型定義.) 注意,這些延伸模組可能會影響 Calendar 物件所使用的行事曆。

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1803 17134 LayoutDirection
2004 19041 AbbreviatedName
2004 19041 GetMuiCompatibleLanguageListFromLanguageTags

建構函式

Language(String)

建立 Language 物件。

屬性

AbbreviatedName

取得 BCP-47 語言標籤的三個字母縮寫。 例如,「en-US」 會轉換成 「eng」。

CurrentInputMethodLanguageTag

取得目前啟用鍵盤配置或輸入法編輯器的 BCP-47 語言標籤, (輸入法) 。

DisplayName

取得適合向使用者顯示以識別語言的當地語系化字串。

LanguageTag

取得這個語言的標準化 BCP-47 語言標記。

LayoutDirection

取得文字和 UI 元素的內容配置方向 (最適合語言) 。

NativeName

取得語言本身的語言名稱。

Script

取得語言的四個字母 ISO 15924 腳本程式碼。

方法

GetExtensionSubtags(String)

擷取目前語言中由單一識別之指定延伸模組的延伸模組向量。

GetMuiCompatibleLanguageListFromLanguageTags(IIterable<String>)

擷取一組 多語系使用者介面 (MUI) 衍生自一或多個 BCP-47 語言標籤的標記。

IsWellFormed(String)

判斷 BCP-47 語言標籤的格式是否正確。

TrySetInputMethodLanguageTag(String)

嘗試設定此語言的標準化 BCP-47 語言標籤。

適用於

另請參閱