CultureInfo.TwoLetterISOLanguageName 属性

定义

获取当前 CultureInfo语言的 ISO 639-1 双字母或 ISO 639-3 三字母代码。

public:
 virtual property System::String ^ TwoLetterISOLanguageName { System::String ^ get(); };
public virtual string TwoLetterISOLanguageName { get; }
member this.TwoLetterISOLanguageName : string
Public Overridable ReadOnly Property TwoLetterISOLanguageName As String

属性值

当前 CultureInfo 的语言的由两个字母构成的 ISO 639-1 代码。 如果没有双字母代码可用,则使用 ISO 639-3 中的三个字母代码。

示例

以下示例列出了其 TwoLetterISOLanguageName 属性不包含双字母语言代码的区域性。

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      // Get all available cultures on the current system.
      CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

      Console.WriteLine("{0,-32} {1,-13} {2,-6}\n", "Display Name",
                        "Name", "TwoLetterISOLanguageName");

      foreach (var culture in cultures) {
         // Exclude custom cultures.
         if ((culture.CultureTypes & CultureTypes.UserCustomCulture) == CultureTypes.UserCustomCulture)
            continue;

         // Exclude all two-letter codes.
         if (culture.TwoLetterISOLanguageName.Length == 2)
            continue;

         Console.WriteLine("{0,-32} {1,-13} {2,-6}", culture.DisplayName,
                           culture.Name, culture.TwoLetterISOLanguageName);
      }
   }
}
// The example output like the following:
//       Display Name                     Name          TwoLetterISOLanguageName
//
//       Upper Sorbian                    hsb           hsb
//       Konkani                          kok           kok
//       Syriac                           syr           syr
//       Tamazight                        tzm           tzm
//       Filipino                         fil           fil
//       Quechua                          quz           quz
//       Sesotho sa Leboa                 nso           nso
//       Mapudungun                       arn           arn
//       Mohawk                           moh           moh
//       Alsatian                         gsw           gsw
//       Sakha                            sah           sah
//       K'iche                           qut           qut
//       Dari                             prs           prs
//       Upper Sorbian (Germany)          hsb-DE        hsb
//       Konkani (India)                  kok-IN        kok
//       Syriac (Syria)                   syr-SY        syr
//       Filipino (Philippines)           fil-PH        fil
//       Quechua (Bolivia)                quz-BO        quz
//       Sesotho sa Leboa (South Africa)  nso-ZA        nso
//       Mapudungun (Chile)               arn-CL        arn
//       Mohawk (Mohawk)                  moh-CA        moh
//       Alsatian (France)                gsw-FR        gsw
//       Sakha (Russia)                   sah-RU        sah
//       K'iche (Guatemala)               qut-GT        qut
//       Dari (Afghanistan)               prs-AF        prs
//       Lower Sorbian (Germany)          dsb-DE        dsb
//       Tamazight (Latin, Algeria)       tzm-Latn-DZ   tzm
//       Quechua (Ecuador)                quz-EC        quz
//       Quechua (Peru)                   quz-PE        quz
//       Sami, Lule (Norway)              smj-NO        smj
//       Sami, Lule (Sweden)              smj-SE        smj
//       Sami, Southern (Norway)          sma-NO        sma
//       Sami, Southern (Sweden)          sma-SE        sma
//       Sami, Skolt (Finland)            sms-FI        sms
//       Sami, Inari (Finland)            smn-FI        smn
//       Sami (Inari)                     smn           smn
//       Sami (Skolt)                     sms           sms
//       Sami (Southern)                  sma           sma
//       Lower Sorbian                    dsb           dsb
//       Sami (Lule)                      smj           smj
//       Tamazight (Latin)                tzm-Latn      tzm
Imports System.Globalization

Module Example
   Public Sub Main()
      ' Get all available cultures on the current system.
      Dim cultures() As CultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures)

      Console.WriteLine("{0,-32} {1,-13} {2,-6}", "Display Name", 
                        "Name", "TwoLetterISOLanguageName")
      Console.WriteLine()
      For Each culture In cultures
         ' Exclude custom cultures.
         If (culture.CultureTypes And CultureTypes.UserCustomCulture) = CultureTypes.UserCustomCulture Then 
            Continue For
         End If
         
         ' Exclude all two-letter codes.
         If culture.TwoLetterISOLanguageName.Length = 2 Then Continue For
         
         Console.WriteLine("{0,-32} {1,-13} {2,-6}", culture.DisplayName,
                           culture.Name, culture.TwoLetterISOLanguageName)
      Next   
   End Sub
End Module
' The example output like the following:
'       Display Name                     Name          TwoLetterISOLanguageName
'       
'       Upper Sorbian                    hsb           hsb
'       Konkani                          kok           kok
'       Syriac                           syr           syr
'       Tamazight                        tzm           tzm
'       Filipino                         fil           fil
'       Quechua                          quz           quz
'       Sesotho sa Leboa                 nso           nso
'       Mapudungun                       arn           arn
'       Mohawk                           moh           moh
'       Alsatian                         gsw           gsw
'       Sakha                            sah           sah
'       K'iche                           qut           qut
'       Dari                             prs           prs
'       Upper Sorbian (Germany)          hsb-DE        hsb
'       Konkani (India)                  kok-IN        kok
'       Syriac (Syria)                   syr-SY        syr
'       Filipino (Philippines)           fil-PH        fil
'       Quechua (Bolivia)                quz-BO        quz
'       Sesotho sa Leboa (South Africa)  nso-ZA        nso
'       Mapudungun (Chile)               arn-CL        arn
'       Mohawk (Mohawk)                  moh-CA        moh
'       Alsatian (France)                gsw-FR        gsw
'       Sakha (Russia)                   sah-RU        sah
'       K'iche (Guatemala)               qut-GT        qut
'       Dari (Afghanistan)               prs-AF        prs
'       Lower Sorbian (Germany)          dsb-DE        dsb
'       Tamazight (Latin, Algeria)       tzm-Latn-DZ   tzm
'       Quechua (Ecuador)                quz-EC        quz
'       Quechua (Peru)                   quz-PE        quz
'       Sami, Lule (Norway)              smj-NO        smj
'       Sami, Lule (Sweden)              smj-SE        smj
'       Sami, Southern (Norway)          sma-NO        sma
'       Sami, Southern (Sweden)          sma-SE        sma
'       Sami, Skolt (Finland)            sms-FI        sms
'       Sami, Inari (Finland)            smn-FI        smn
'       Sami (Inari)                     smn           smn
'       Sami (Skolt)                     sms           sms
'       Sami (Southern)                  sma           sma
'       Lower Sorbian                    dsb           dsb
'       Sami (Lule)                      smj           smj
'       Tamazight (Latin)                tzm-Latn      tzm

注解

例如,英语的双字母缩写为“en”。 TwoLetterISOLanguageName固定区域性的属性值为“iv”。

注意

在进程之间通信或保留数据时,通常最好使用完整的 CultureInfo.Name。 仅使用该语言可能会丢失上下文和数据。

如果 ISO 639-1 未为特定区域性定义两个字母的语言代码,则 TwoLetterISOLanguageName 属性将返回一个包含三个或更多个字母的字符串。 有关详细信息,请参阅此示例。

适用于

另请参阅