Click here to Skip to main content
6,594,932 members and growing! (15,616 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » .NET Framework » Utilities     Advanced License: The Code Project Open License (CPOL)

Culture and Region Information Tool for .NET 2.0

By Paulo Morgado

A Culture and Region Information tool for .NET 2.0 based on System.Globalization.CultureAndRegionInfoBuilder
C# 2.0, Windows, .NET 3.0, ASP.NET, VS2005, Architect, Dev
Posted:24 Jan 2007
Updated:29 Jan 2007
Views:16,686
Bookmarked:15 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
8 votes for this article.
Popularity: 2.87 Rating: 3.18 out of 5
3 votes, 37.5%
1

2
2 votes, 25.0%
3

4
3 votes, 37.5%
5

Introduction

Defining custom culture and region information is common practice in many enterprise environments.

In the .NET Framework 2.0, we can use the CultureAndRegionInfoBuilder class to build a custom culture that is new or based on an existing culture and region. The custom culture can be installed on a computer and subsequently used by any application running on that computer.

Using this class, I've built a small command line tool to extract, register and unregister culture and region information.

The Tool

The tool is just a simple command line parser that calls methods of the CultureAndRegionInfoBuilder class.

Extracting Culture and Region Information

For extracting culture and region information, an instance of CultureAndRegionInfoBuilder is created for the specified culture with the Replacement modifier and saved to the specified file.

private static void ExtractCultureAndRegionInfo(string cultureName, string filenName)
{
    FileInfo fileInfo = GetFileInfo(filenName);
    if (fileInfo.Exists)
    {
        fileInfo.Delete();
    }
    CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder
        = new CultureAndRegionInfoBuilder
        (cultureName, CultureAndRegionModifiers.Replacement);
    cultureAndRegionInfoBuilder.Save(fileInfo.FullName);
}

Registering Culture and Region Information

For registering culture and region information, an instance of CultureAndRegionInfoBuilder is created from the specified LDML definition file and registered.

private static void RegisterCustomCulture(string filenName)
{
    FileInfo fileInfo = GetFileInfo(filenName);
    CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder =
    CultureAndRegionInfoBuilder.CreateFromLdml(fileInfo.FullName);
    cultureAndRegionInfoBuilder.Register();
}

Unregistering Culture and Region Information

For unregistering culture and region information, the Unregister method of CultureAndRegionInfoBuilder is called for the specified culture.

private static void UnregisterCustomCulture(string cultureName)
{
    CultureAndRegionInfoBuilder.Unregister(cultureName);
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Paulo Morgado


Member

Paulo has a bachelor degree in Electronics and Telecommunications (Digital Systems) by the Instituto Superior de Engenharia de Lisboa and a degree of licentiate in Informatics by the Faculdade de Ciências da Universidade Nova de Lisboa and na MCSD for Microsoft .NET certification.


Paulo has also a MCSD for the .NET Framework certification.


Paulo works at Espírito Santo Informática, ACE as a developer/software architect.


Paulo contributes in the Microsoft Portuguese newsgroups and the PontoNetPT community answering questions about software development posted in the (with special focus on the .NET framework).


His growing interest in software architecture drives his participation in the Portuguese Group of Software Architecture – GASP.


His contributions to the community has earned him Microsoft's Most Valuable Professional award.


Blog: http://www.PauloMorgado.NET/


Occupation: Software Developer (Senior)
Company: Paulo Morgado
Location: Portugal Portugal

Other popular .NET Framework articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
QuestionHelp PinmemberMarkRedman6:30 29 Jan '07  
AnswerRe: Help PinmemberM.Lansdaal11:14 29 Jan '07  
AnswerRe: Help PinmemberPaulo Morgado12:59 29 Jan '07  
AnswerRe: Help PinmemberMarkRedman13:47 29 Jan '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Jan 2007
Editor: Deeksha Shenoy
Copyright 2007 by Paulo Morgado
Everything else Copyright © CodeProject, 1999-2009
Web12 | Advertise on the Code Project