CultureInfo.Parent プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)
構文
解説
カルチャは階層構造になっています。たとえば、特定のカルチャの親はニュートラル カルチャであり、ニュートラル カルチャの親は InvariantCulture であり、InvariantCulture の親はインバリアント カルチャ自体となっています。親カルチャは、その子の間で共通する情報セットだけを持ちます。
システム内で特定のカルチャのリソースが利用できない場合は、ニュートラル カルチャのリソースが使用されます。ニュートラル カルチャのリソースが利用できない場合は、メイン アセンブリに埋め込まれているリソースが使用されます。リソース フォールバック プロセスの詳細については、「リソースのパッケージ化と配置」を参照してください。
Windows API のカルチャの一覧は、.NET Framework のカルチャの一覧と若干異なります。たとえば、カルチャ識別子 0x7C04 のニュートラル カルチャ zh-CHT "繁体字中国語" は Windows API では利用できません。Windows との相互運用 (たとえば、p/invoke 機構を通じた相互運用) が必要な場合は、オペレーティング システムで定義されている特定のカルチャを使用してください。これにより、同一の LCID で識別される等価な Windows ロケールとの一貫性が確保されます。
中国語を使用する特定の各カルチャの親カルチャを決定するコードの例を次に示します。
Imports System Imports System.Globalization Public Class SamplesCultureInfo Public Shared Sub Main() ' Prints the header. Console.WriteLine("SPECIFIC CULTURE PARENT CULTURE") ' Determines the specific cultures that use the Chinese language, and displays the parent culture. Dim ci As CultureInfo For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures) If ci.TwoLetterISOLanguageName = "zh" Then Console.Write("0x{0} {1} {2,-37}", ci.LCID.ToString("X4"), ci.Name, ci.EnglishName) Console.WriteLine("0x{0} {1} {2}", ci.Parent.LCID.ToString("X4"), ci.Parent.Name, ci.Parent.EnglishName) End If Next ci End Sub 'Main End Class 'SamplesCultureInfo 'This code produces the following output. ' 'SPECIFIC CULTURE PARENT CULTURE '0x0404 zh-TW Chinese (Taiwan) 0x7C04 zh-CHT Chinese (Traditional) '0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified) '0x0C04 zh-HK Chinese (Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) '0x1004 zh-SG Chinese (Singapore) 0x0004 zh-CHS Chinese (Simplified) '0x1404 zh-MO Chinese (Macau S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) '
using System; using System.Globalization; public class SamplesCultureInfo { public static void Main() { // Prints the header. Console.WriteLine( "SPECIFIC CULTURE PARENT CULTURE" ); // Determines the specific cultures that use the Chinese language, and displays the parent culture. foreach ( CultureInfo ci in CultureInfo.GetCultures( CultureTypes.SpecificCultures ) ) { if ( ci.TwoLetterISOLanguageName == "zh" ) { Console.Write( "0x{0} {1} {2,-37}", ci.LCID.ToString("X4"), ci.Name, ci.EnglishName ); Console.WriteLine( "0x{0} {1} {2}", ci.Parent.LCID.ToString("X4"), ci.Parent.Name, ci.Parent.EnglishName ); } } } } /* This code produces the following output. SPECIFIC CULTURE PARENT CULTURE 0x0404 zh-TW Chinese (Taiwan) 0x7C04 zh-CHT Chinese (Traditional) 0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified) 0x0C04 zh-HK Chinese (Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) 0x1004 zh-SG Chinese (Singapore) 0x0004 zh-CHS Chinese (Simplified) 0x1404 zh-MO Chinese (Macau S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) */
using namespace System; using namespace System::Globalization; int main() { // Prints the header. Console::WriteLine( "SPECIFIC CULTURE PARENT CULTURE" ); // Determines the specific cultures that use the Chinese language, // and displays the parent culture. System::Collections::IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator(); while ( en->MoveNext() ) { CultureInfo^ ci = safe_cast<CultureInfo^>(en->Current); if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) ) { Console::Write( "0x{0} {1} {2,-37}", ci->LCID.ToString( "X4" ), ci->Name, ci->EnglishName ); Console::WriteLine( "0x{0} {1} {2}", ci->Parent->LCID.ToString( "X4" ), ci->Parent->Name, ci->Parent->EnglishName ); } } } /* This code produces the following output. SPECIFIC CULTURE PARENT CULTURE 0x0404 zh-TW Chinese (Taiwan) 0x7C04 zh-CHT Chinese (Traditional) 0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified) 0x0C04 zh-HK Chinese (Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) 0x1004 zh-SG Chinese (Singapore) 0x0004 zh-CHS Chinese (Simplified) 0x1404 zh-MO Chinese (Macao S.A.R.) 0x0004 zh-CHS Chinese (Simplified) */
import System.* ; import System.Globalization.* ; public class SamplesCultureInfo { public static void main(String[] args) { // Prints the header. Console.WriteLine("SPECIFIC CULTURE " + " PARENT CULTURE"); // Determines the specific cultures that use the Chinese language, // and displays the parent culture. for(int iCtr=0; iCtr < (CultureInfo.GetCultures(CultureTypes.SpecificCultures). length); iCtr++) { CultureInfo ci = CultureInfo.GetCultures(CultureTypes.SpecificCultures)[iCtr]; if (ci.get_TwoLetterISOLanguageName().equalsIgnoreCase("zh")) { Console.Write("0x{0} {1} {2,-37}", ((System.Int32 ) ci.get_LCID()).ToString("X4") , ci.get_Name(), ci.get_EnglishName()); Console.WriteLine("0x{0} {1} {2}", ((System.Int32 )ci.get_Parent().get_LCID()).ToString("X4") , ci.get_Parent().get_Name(), ci.get_Parent().get_EnglishName()); } } } //main } //SamplesCultureInfo /* This code produces the following output. SPECIFIC CULTURE PARENT CULTURE 0x0404 zh-TW Chinese (Taiwan) 0x7C04 zh-CHT Chinese (Traditional) 0x0804 zh-CN Chinese (People's Republic of China) 0x0004 zh-CHS Chinese (Simplified) 0x0C04 zh-HK Chinese (Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) 0x1004 zh-SG Chinese (Singapore) 0x0004 zh-CHS Chinese (Simplified) 0x1404 zh-MO Chinese (Macau S.A.R.) 0x0004 zh-CHS Chinese (Simplified) */
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- CultureInfo.Parent プロパティのページへのリンク