다음을 통해 공유


방법: 사용자 지정 Culture 만들기

업데이트: 2010년 12월

.NET Framework 및 Windows 운영 체제에서 제공하는 미리 정의된 문화권에서는 국가/지역에서 사용되는 언어와 달력 및 문자열, 날짜, 숫자를 형식 지정, 구문 분석 및 비교하는 데 사용되는 텍스트 규칙을 지정합니다. 그러나 미리 정의된 문화권에서 필요한 정보를 제공하지 않는 경우에는 사용자 지정 문화권을 만들 수 있습니다.

사용자 지정 문화권을 정의하고 만들려면

  1. CultureAndRegionInfoBuilder 개체를 사용하여 사용자 지정 문화권을 정의하고 이름을 지정합니다. 사용자 지정 문화권은 완전히 새로운 문화권이거나 기존 문화권 기반의 새로운 문화권일 수도 있고, 기존 .NET Framework 문화권이나 Windows 로캘을 대체하는 문화권일 수도 있습니다.

    새 문화권의 경우 CultureAndRegionInfoBuilder.LoadDataFromCultureInfo 메서드를 호출하여 얻은 문화권 정보와 CultureAndRegionInfoBuilder.LoadDataFromRegionInfo 메서드를 호출하여 얻은 지역 정보로 CultureAndRegionInfoBuilder 개체 속성을 채울 수 있습니다. 대체 문화권의 경우에는 대체되는 문화권의 속성을 토대로 CultureAndRegionInfoBuilder 개체 속성이 자동으로 채워집니다.

  2. 필요에 따라 CultureAndRegionInfoBuilder 개체의 속성을 수정합니다.

  3. CultureAndRegionInfoBuilder.Register 메서드를 호출하여 사용자 지정 문화권을 등록합니다. 등록 프로세스에서 다음 작업이 수행됩니다.

    • .nip 파일을 만듭니다. 이 파일에는 CultureAndRegionInfoBuilder 개체에 정의된 정보가 포함됩니다.

    • .nip 파일을 컴퓨터의 %windir%\Globalization 시스템 디렉터리에 저장합니다. 이렇게 하면 컴퓨터의 전원을 꺼도 문화권 정보가 컴퓨터에 유지됩니다. .nlp 파일이 시스템 디렉터리에 저장되므로 이 컴퓨터에 대한 관리자 권한이 필요합니다.

    • 다음에 사용자 지정 문화권을 새로 만들기 위한 요청이 있을 때 내부 캐시 대신 %windir%\Globalization 시스템 디렉터리를 검색하도록 .NET Framework를 준비합니다.

    주의 정보주의

    사용자 지정 문화권을 등록할 컴퓨터에 대한 관리자 권한이 없는 경우 CultureAndRegionInfoBuilder.Register 메서드를 호출하면 UnauthorizedAccessException이 throw됩니다.리플렉션을 사용하여 전용 메서드를 호출하는 방법으로 이 요구 사항을 해결할 수 있습니다.자세한 내용은 방법: 관리 권한 없이 사용자 지정 문화권 저장을 참조하십시오.

    이제 사용자 지정 문화권은 컴퓨터에서 미리 정의된 모든 .NET Framework 문화권이나 Windows 로캘과 동일한 상태입니다. CultureAndRegionInfoBuilder.Unregister 메서드를 호출하여 .nip 파일이 로컬 컴퓨터에서 제거될 때까지 사용자 지정 문화권을 사용할 수 있습니다.

  4. 사용자 지정 문화권을 기반으로 CultureInfo 개체를 인스턴스화하려면 CultureInfo 클래스 생성자에서 해당 문화권의 이름을 지정합니다.

예제

다음 예제에서는 CultureAndRegionInfoBuilder 클래스를 사용하여 x-en-US-sample이라는 사용자 지정 문화권을 정의하고 등록한 다음 사용자 지정 문화권에 대한 CultureInfo 개체를 생성합니다. 또한 CultureAndRegionInfoBuilderCultureInfo 개체의 일부 해당 속성을 보여 줍니다.

' This example demonstrates the System.Globalization.Culture-
' AndRegionInfoBuilder Register method.
' Compile this code example with a reference to sysglobl.dll.

Imports System
Imports System.Globalization

Class Sample
    Public Shared Sub Main() 
        Dim cib As CultureAndRegionInfoBuilder = Nothing
        Try
            ' Create a CultureAndRegionInfoBuilder object named "x-en-US-sample".
            Console.WriteLine("Create and explore the CultureAndRegionInfoBuilder..." & vbCrLf)
            cib = New CultureAndRegionInfoBuilder("x-en-US-sample", CultureAndRegionModifiers.None)

            ' Populate the new CultureAndRegionInfoBuilder object with culture information.
            Dim ci As New CultureInfo("en-US")
            cib.LoadDataFromCultureInfo(ci)

            ' Populate the new CultureAndRegionInfoBuilder object with region information.
            Dim ri As New RegionInfo("US")
            cib.LoadDataFromRegionInfo(ri)

            ' Display some of the properties of the CultureAndRegionInfoBuilder object.
            Console.WriteLine("CultureName:. . . . . . . . . . {0}", cib.CultureName)
            Console.WriteLine("CultureEnglishName: . . . . . . {0}", cib.CultureEnglishName)
            Console.WriteLine("CultureNativeName:. . . . . . . {0}", cib.CultureNativeName)
            Console.WriteLine("GeoId:. . . . . . . . . . . . . {0}", cib.GeoId)
            Console.WriteLine("IsMetric: . . . . . . . . . . . {0}", cib.IsMetric)
            Console.WriteLine("ISOCurrencySymbol:. . . . . . . {0}", cib.ISOCurrencySymbol)
            Console.WriteLine("RegionEnglishName:. . . . . . . {0}", cib.RegionEnglishName)
            Console.WriteLine("RegionName: . . . . . . . . . . {0}", cib.RegionName)
            Console.WriteLine("RegionNativeName: . . . . . . . {0}", cib.RegionNativeName)
            Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", cib.ThreeLetterISOLanguageName)
            Console.WriteLine("ThreeLetterISORegionName: . . . {0}", cib.ThreeLetterISORegionName)
            Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", cib.ThreeLetterWindowsLanguageName)
            Console.WriteLine("ThreeLetterWindowsRegionName: . {0}", cib.ThreeLetterWindowsRegionName)
            Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", cib.TwoLetterISOLanguageName)
            Console.WriteLine("TwoLetterISORegionName: . . . . {0}", cib.TwoLetterISORegionName)
            Console.WriteLine()

            ' Register the custom culture.
            Console.WriteLine("Register the custom culture...")
            cib.Register()

            ' Display some of the properties of the custom culture.
            Console.WriteLine("Create and explore the custom culture..." & vbCrLf)
            ci = New CultureInfo("x-en-US-sample")

            Console.WriteLine("Name: . . . . . . . . . . . . . {0}", ci.Name)
            Console.WriteLine("EnglishName:. . . . . . . . . . {0}", ci.EnglishName)
            Console.WriteLine("NativeName: . . . . . . . . . . {0}", ci.NativeName)
            Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", ci.TwoLetterISOLanguageName)
            Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", ci.ThreeLetterISOLanguageName)
            Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", ci.ThreeLetterWindowsLanguageName)

            Console.WriteLine(vbCrLf & "Note:" & vbCrLf & "Use the example in the " & _
                              "Unregister method topic to remove the custom culture.")
        Catch e As Exception
            Console.WriteLine(e)
        End Try

    End Sub 'Main
End Class 'Sample

'This code example produces the following results:
'
'Create and explore the CultureAndRegionInfoBuilder...
'
'CultureName:. . . . . . . . . . x-en-US-sample
'CultureEnglishName: . . . . . . English (United States)
'CultureNativeName:. . . . . . . English (United States)
'GeoId:. . . . . . . . . . . . . 244
'IsMetric: . . . . . . . . . . . False
'ISOCurrencySymbol:. . . . . . . USD
'RegionEnglishName:. . . . . . . United States
'RegionName: . . . . . . . . . . x-en-US-sample
'RegionNativeName: . . . . . . . United States
'ThreeLetterISOLanguageName: . . eng
'ThreeLetterISORegionName: . . . USA
'ThreeLetterWindowsLanguageName: ENU
'ThreeLetterWindowsRegionName: . USA
'TwoLetterISOLanguageName: . . . en
'TwoLetterISORegionName: . . . . US
'
'Register the custom culture...
'Create and explore the custom culture...
'
'Name: . . . . . . . . . . . . . x-en-US-sample
'EnglishName:. . . . . . . . . . English (United States)
'NativeName: . . . . . . . . . . English (United States)
'TwoLetterISOLanguageName: . . . en
'ThreeLetterISOLanguageName: . . eng
'ThreeLetterWindowsLanguageName: ENU
'
'Note:
'Use the example in the Unregister method topic to remove the custom culture.
'
// This example demonstrates the System.Globalization.Culture-
// AndRegionInfoBuilder Register method.
// Compile this code example with a reference to sysglobl.dll.

using System;
using System.Globalization;

class Sample 
{
    public static void Main() 
    {
    CultureAndRegionInfoBuilder cib = null;
    try 
    {
// Create a CultureAndRegionInfoBuilder object named "x-en-US-sample".
    Console.WriteLine("Create and explore the CultureAndRegionInfoBuilder...\n");
    cib = new CultureAndRegionInfoBuilder(
                         "x-en-US-sample", CultureAndRegionModifiers.None);

// Populate the new CultureAndRegionInfoBuilder object with culture information.
    CultureInfo ci = new CultureInfo("en-US");
    cib.LoadDataFromCultureInfo(ci);

// Populate the new CultureAndRegionInfoBuilder object with region information.
    RegionInfo  ri = new RegionInfo("US");
    cib.LoadDataFromRegionInfo(ri);

// Display some of the properties of the CultureAndRegionInfoBuilder object.
    Console.WriteLine("CultureName:. . . . . . . . . . {0}", cib.CultureName);
    Console.WriteLine("CultureEnglishName: . . . . . . {0}", cib.CultureEnglishName);
    Console.WriteLine("CultureNativeName:. . . . . . . {0}", cib.CultureNativeName);
    Console.WriteLine("GeoId:. . . . . . . . . . . . . {0}", cib.GeoId);
    Console.WriteLine("IsMetric: . . . . . . . . . . . {0}", cib.IsMetric);
    Console.WriteLine("ISOCurrencySymbol:. . . . . . . {0}", cib.ISOCurrencySymbol);
    Console.WriteLine("RegionEnglishName:. . . . . . . {0}", cib.RegionEnglishName);
    Console.WriteLine("RegionName: . . . . . . . . . . {0}", cib.RegionName);
    Console.WriteLine("RegionNativeName: . . . . . . . {0}", cib.RegionNativeName);
    Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", cib.ThreeLetterISOLanguageName);
    Console.WriteLine("ThreeLetterISORegionName: . . . {0}", cib.ThreeLetterISORegionName);
    Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", cib.ThreeLetterWindowsLanguageName);
    Console.WriteLine("ThreeLetterWindowsRegionName: . {0}", cib.ThreeLetterWindowsRegionName);
    Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", cib.TwoLetterISOLanguageName);
    Console.WriteLine("TwoLetterISORegionName: . . . . {0}", cib.TwoLetterISORegionName);
    Console.WriteLine();

// Register the custom culture.
    Console.WriteLine("Register the custom culture...");
    cib.Register();

// Display some of the properties of the custom culture.
    Console.WriteLine("Create and explore the custom culture...\n");
    ci = new CultureInfo("x-en-US-sample");

    Console.WriteLine("Name: . . . . . . . . . . . . . {0}", ci.Name);
    Console.WriteLine("EnglishName:. . . . . . . . . . {0}", ci.EnglishName);
    Console.WriteLine("NativeName: . . . . . . . . . . {0}", ci.NativeName);
    Console.WriteLine("TwoLetterISOLanguageName: . . . {0}", ci.TwoLetterISOLanguageName);
    Console.WriteLine("ThreeLetterISOLanguageName: . . {0}", ci.ThreeLetterISOLanguageName);
    Console.WriteLine("ThreeLetterWindowsLanguageName: {0}", ci.ThreeLetterWindowsLanguageName);

    Console.WriteLine("\nNote:\n" +
        "Use the example in the Unregister method topic to remove the custom culture.");
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
    }
    }
}
/*
This code example produces the following results:

Create and explore the CultureAndRegionInfoBuilder...

CultureName:. . . . . . . . . . x-en-US-sample
CultureEnglishName: . . . . . . English (United States)
CultureNativeName:. . . . . . . English (United States)
GeoId:. . . . . . . . . . . . . 244
IsMetric: . . . . . . . . . . . False
ISOCurrencySymbol:. . . . . . . USD
RegionEnglishName:. . . . . . . United States
RegionName: . . . . . . . . . . x-en-US-sample
RegionNativeName: . . . . . . . United States
ThreeLetterISOLanguageName: . . eng
ThreeLetterISORegionName: . . . USA
ThreeLetterWindowsLanguageName: ENU
ThreeLetterWindowsRegionName: . USA
TwoLetterISOLanguageName: . . . en
TwoLetterISORegionName: . . . . US

Register the custom culture...
Create and explore the custom culture...

Name: . . . . . . . . . . . . . x-en-US-sample
EnglishName:. . . . . . . . . . English (United States)
NativeName: . . . . . . . . . . English (United States)
TwoLetterISOLanguageName: . . . en
ThreeLetterISOLanguageName: . . eng
ThreeLetterWindowsLanguageName: ENU

Note:
Use the example in the Unregister method topic to remove the custom culture.

*/

참고 항목

참조

CultureInfo

CultureAndRegionInfoBuilder

CultureAndRegionModifiers

기타 리소스

인코딩 및 지역화

변경 기록

날짜

변경 내용

이유

2010년 12월

관리 권한 없이 사용자 지정 문화권을 저장하는 데 대한 참고 사항이 추가되었습니다.

향상된 기능 관련 정보