Showing posts with label internationalization. Show all posts
Showing posts with label internationalization. Show all posts

Sunday, April 6, 2008

i18n for Chinese in .NET Framework 3.5

Well, I upgraded my development and production servers to .NET Framework 3.5.

I'm really not taking advantage of the .NET Framework 3.5 additions (lambda functions, LINQ) yet. Also, I haven't made a decision yet on LINQ vs. NHibernate. However, I've already made a significant time investment in NHibernate, so it would really take a lot of convincing to move to LINQ, unless there is a clear path for doing so from NHibernate.

I had noticed that on all the MSDN pages there was a little section that appeared as follows:





Figured it would be best to get on the latest version.

For the most part, the upgrade is painless. It was just a matter of downloading / running the .NET Framework 3.5 installer dotNetFx35setup from Microsoft. No code changes were required. However, one change I feel I should make, even though everything is still running is refactoring my project so that it uses the latest (and correct) Neutral Cultures for Simplified and Traditional Chinese. Here are the entries for both from the latest MSDN System.Globalization.CultureInfo documentation.

Culture/Language Name

Culture
zh-Hans Chinese (Simplified)
zh-Hant Chinese (Traditional)

I've had a bit of discussion with Shawn Steele on his blog about the latest .NET Framework changing Simplfied from zh-CHS to zh-Hans and Traditional from zh-CHT to zh-Hant. Although the old zh-CHS and zh-CHT are still supported, I don't want to use a deprecated method for getting to my RESX files.

Tuesday, March 25, 2008

Localization in ASP.NET

Working on my International BlogEngine.NET theme helped me round out my understanding of the System.Globalization namespace, specifically the nifty CultureInfo class.

I have been working with CultureInfo on a current project in order to display content in English and Chinese WITHOUT having to make multiple copies of each .aspx file. Originally, I had used this article (which coincidentally the author is localizing for Chinese): Localization in ASP.NET 2.0. This was a great help in getting started.

However, I learned a bit more while working on the International BlogEngine.NET theme (which made me go back to my current project and restructure a few things):

The key to understanding Internationalization in .NET is the CultureInfo class and how Cultures are named.

  • Three important types of Cultures: Invariant, Neutral, and Specific. The Invariant is a default, and is represented by an empty String.
  • Neutral Cultures are usually represented by a lowercase two-character String, such as en (English), fr (French), es (Spanish), and represent a language, with no information about location.
  • Specific Cultures represent a language and a location and are usually represented by a lowercase-two character String (language), plus an uppercase two character String (Country), separated by a dash. Some examples include: en-GB (English, Great Britian), en-US (English, U.S.), fr-CA (French, Canada).
  • The Culture Names for Chinese are a bit odd. zh-CHS represents Simplified Chinese, the form of written Chinese used by the mainland. zh-CHT represents Traditional Chinese, used by Hong Kong and Taiwan. There is no culture with the name of just zh to represent Chinese in general. I learned this the hard way when attempting to simplify the names of my Resource files (.resx files) so that they did not represent a specific culture and tried to use just zh for my Simplified Chinese, which needless to say did not work.
  • There are a handful of other exceptions to be aware of.


Here is a table (pulled from MSDN):

Culture Name

Language-Country/Region

"" (empty string)

invariant culture

af

Afrikaans

af-ZA

Afrikaans - South Africa

sq

Albanian

sq-AL

Albanian - Albania

ar

Arabic

ar-DZ

Arabic - Algeria

ar-BH

Arabic - Bahrain

ar-EG

Arabic - Egypt

ar-IQ

Arabic - Iraq

ar-JO

Arabic - Jordan

ar-KW

Arabic - Kuwait

ar-LB

Arabic - Lebanon

ar-LY

Arabic - Libya

ar-MA

Arabic - Morocco

ar-OM

Arabic - Oman

ar-QA

Arabic - Qatar

ar-SA

Arabic - Saudi Arabia

ar-SY

Arabic - Syria

ar-TN

Arabic - Tunisia

ar-AE

Arabic - United Arab Emirates

ar-YE

Arabic - Yemen

hy

Armenian

hy-AM

Armenian - Armenia

az

Azeri

az-AZ-Cyrl

Azeri (Cyrillic) - Azerbaijan

az-AZ-Latn

Azeri (Latin) - Azerbaijan

eu

Basque

eu-ES

Basque - Basque

be

Belarusian

be-BY

Belarusian - Belarus

bg

Bulgarian

bg-BG

Bulgarian - Bulgaria

ca

Catalan

ca-ES

Catalan - Catalan

zh-HK

Chinese - Hong Kong SAR

zh-MO

Chinese - Macao SAR

zh-CN

Chinese - China

zh-CHS

Chinese (Simplified)

zh-SG

Chinese - Singapore

zh-TW

Chinese - Taiwan

zh-CHT

Chinese (Traditional)

hr

Croatian

hr-HR

Croatian - Croatia

cs

Czech

cs-CZ

Czech - Czech Republic

da

Danish

da-DK

Danish - Denmark

div

Dhivehi

div-MV

Dhivehi - Maldives

nl

Dutch

nl-BE

Dutch - Belgium

nl-NL

Dutch - The Netherlands

en

English

en-AU

English - Australia

en-BZ

English - Belize

en-CA

English - Canada

en-CB

English - Caribbean

en-IE

English - Ireland

en-JM

English - Jamaica

en-NZ

English - New Zealand

en-PH

English - Philippines

en-ZA

English - South Africa

en-TT

English - Trinidad and Tobago

en-GB

English - United Kingdom

en-US

English - United States

en-ZW

English - Zimbabwe

et

Estonian

et-EE

Estonian - Estonia

fo

Faroese

fo-FO

Faroese - Faroe Islands

fa

Farsi

fa-IR

Farsi - Iran

fi

Finnish

fi-FI

Finnish - Finland

fr

French

fr-BE

French - Belgium

fr-CA

French - Canada

fr-FR

French - France

fr-LU

French - Luxembourg

fr-MC

French - Monaco

fr-CH

French - Switzerland

gl

Galician

gl-ES

Galician - Galician

ka

Georgian

ka-GE

Georgian - Georgia

de

German

de-AT

German - Austria

de-DE

German - Germany

de-LI

German - Liechtenstein

de-LU

German - Luxembourg

de-CH

German - Switzerland

el

Greek

el-GR

Greek - Greece

gu

Gujarati

gu-IN

Gujarati - India

he

Hebrew

he-IL

Hebrew - Israel

hi

Hindi

hi-IN

Hindi - India

hu

Hungarian

hu-HU

Hungarian - Hungary

is

Icelandic

is-IS

Icelandic - Iceland

id

Indonesian

id-ID

Indonesian - Indonesia

it

Italian

it-IT

Italian - Italy

it-CH

Italian - Switzerland

ja

Japanese

ja-JP

Japanese - Japan

kn

Kannada

kn-IN

Kannada - India

kk

Kazakh

kk-KZ

Kazakh - Kazakhstan

kok

Konkani

kok-IN

Konkani - India

ko

Korean

ko-KR

Korean - Korea

ky

Kyrgyz

ky-KG

Kyrgyz - Kyrgyzstan

lv

Latvian

lv-LV

Latvian - Latvia

lt

Lithuanian

lt-LT

Lithuanian - Lithuania

mk

Macedonian

mk-MK

Macedonian - Former Yugoslav Republic of Macedonia

ms

Malay

ms-BN

Malay - Brunei

ms-MY

Malay - Malaysia

mr

Marathi

mr-IN

Marathi - India

mn

Mongolian

mn-MN

Mongolian - Mongolia

no

Norwegian

nb-NO

Norwegian (Bokmål) - Norway

nn-NO

Norwegian (Nynorsk) - Norway

pl

Polish

pl-PL

Polish - Poland

pt

Portuguese

pt-BR

Portuguese - Brazil

pt-PT

Portuguese - Portugal

pa

Punjabi

pa-IN

Punjabi - India

ro

Romanian

ro-RO

Romanian - Romania

ru

Russian

ru-RU

Russian - Russia

sa

Sanskrit

sa-IN

Sanskrit - India

sr-SP-Cyrl

Serbian (Cyrillic) - Serbia

sr-SP-Latn

Serbian (Latin) - Serbia

sk

Slovak

sk-SK

Slovak - Slovakia

sl

Slovenian

sl-SI

Slovenian - Slovenia

es

Spanish

es-AR

Spanish - Argentina

es-BO

Spanish - Bolivia

es-CL

Spanish - Chile

es-CO

Spanish - Colombia

es-CR

Spanish - Costa Rica

es-DO

Spanish - Dominican Republic

es-EC

Spanish - Ecuador

es-SV

Spanish - El Salvador

es-GT

Spanish - Guatemala

es-HN

Spanish - Honduras

es-MX

Spanish - Mexico

es-NI

Spanish - Nicaragua

es-PA

Spanish - Panama

es-PY

Spanish - Paraguay

es-PE

Spanish - Peru

es-PR

Spanish - Puerto Rico

es-ES

Spanish - Spain

es-UY

Spanish - Uruguay

es-VE

Spanish - Venezuela

sw

Swahili

sw-KE

Swahili - Kenya

sv

Swedish

sv-FI

Swedish - Finland

sv-SE

Swedish - Sweden

syr

Syriac

syr-SY

Syriac - Syria

ta

Tamil

ta-IN

Tamil - India

tt

Tatar

tt-RU

Tatar - Russia

te

Telugu

te-IN

Telugu - India

th

Thai

th-TH

Thai - Thailand

tr

Turkish

tr-TR

Turkish - Turkey

uk

Ukrainian

uk-UA

Ukrainian - Ukraine

ur

Urdu

ur-PK

Urdu - Pakistan

uz

Uzbek

uz-UZ-Cyrl

Uzbek (Cyrillic) - Uzbekistan

uz-UZ-Latn

Uzbek (Latin) - Uzbekistan

vi

Vietnamese

vi-VN

Vietnamese - Vietnam