Thursday, March 15, 2007

Session.LCID (LOCALE ID)

When we are developing a website using ASP script, sometime we had to format dates, numbers, currency, etc. by ourself. And relying on the version of Windows that was installed on the server, it is not good idea in case you moved sites from say The United States to a United Kingdom provider. With IIS4 and IIS5 (Windows NT4 and Windows 2000 respectively) you only need to set the LOCALE ID (Session.LCID) and everything is done for you. The Session.LCID is a read/write property, meaning you can assign a value to it as well as read its current value.

Session.LCID has session scope, which means you can just add one line of code to your global.asa file and ASP does the rest for you. Just remember that if you assign a new value to the Session.LCID it will override global.asa and will remain until a new value is set or the session is ended.

Below you can see locale id's for the US and the UK as well as how dates are formatted using these locales.

Session.LCID = 1033 'This is the English(United States) format.

Short Date : 3/15/2007
Long Date : Thursday, March 15, 2007
Time : 12:11:02 AM
Currency : $9.95

Session.LCID = 2057 'This is the English(British) format

Short Date : 15/03/2007
Long Date : 15 March 2007
Time : 00:11:02
Currency : Ј10.00

When working with databases, you will want to also set the format of the date field to correspond with the LCID that is being used in the script. You can do this by going into the design view and setting the format to dd/mm/yyyy or the format you are using.

Below is a table of the LCIDs, and the corresponding language that you have available:

LOCALE ID :

LCID____Language
-----------------------------
1078____Afrikaans
1052____Albanian
5121____Arabic(Algeria)
15361___Arabic(Bahrain)
3073____Arabic(Egypt)
2049____Arabic(Iraq)
11265___Arabic(Jordan)
13313___Arabic(Kuwait)
12289___Arabic(Lebanon)
4097____Arabic(Libya)
6145____Arabic(Morocco)
8193____Arabic(Oman)
16385___Arabic(Qatar)
1025____Arabic(Saudi Arabia)
10241___Arabic(Syria)
7169____Arabic(Tunisia)
14337___Arabic(U.A.E.)
9217____Arabic(Yemen)
1069____Basque
1059____Belarusian
1026____Bulgarian
1027____Catalan
3076____Chinese(Hong Kong)
2052____Chinese(PRC)
4100____Chinese(Singapore)
1028____Chinese(Taiwan)
1050____Croatian
1029____Czech
1030____Danish
2067____Dutch(Belgian)
1043____Dutch(Standard)
9_______English
3081____English(Australian)
10249___English(Belize)
2057____English(British)
4105____English(Canadian)
9225____English(Caribbean)
6153____English(Ireland)
8201____English(Jamaica)
5129____English(New Zealand)
7177____English(South Africa)
11273___English(Trinidad)
1033____English(United States)
1061____Estonian
1080____Faeroese
1065____Farsi
1035____Finnish
2060____French(Belgian)
3084____French(Canadian)
5132____French(Luxembourg)
1036____French(Standard)
4108____French(Swiss)
2108____Gaelic(Irish)
1084____Gaelic(Scots)
3079____German(Austrian)
5127____German(Liechtenstein)
4103____German(Luxembourg)
1031____German(Standard)
2055____German(Swiss)
1032____Greek
1037____Hebrew
1081____Hindi
1038____Hungarian
1039____Icelandic
1057____Indonesian
1040____Italian(Standard)
2064____Italian(Swiss)
1041____Japanese
1042____Korean
2066____Korean(Johab)
1062____Latvian
1063____Lithuanian
1071____Macedonian
1086____Malaysian
1082____Maltese
1044____Norwegian(Bokmal)
2068____Norwegian(Nynorsk)
1045____Polish
1046____Portuguese(Brazilian)
2070____Portuguese(Standard)
1047____Rhaeto-Romanic
1048____Romanian
2072____Romanian(Moldavia)
1049____Russian
2073____Russian(Moldavia)
1083____Sami(Lappish)
3098____Serbian(Cyrillic)
2074____Serbian(Latin)
1051____Slovak
1060____Slovenian
1070____Sorbian
11274___Spanish(Argentina)
16394___Spanish(Bolivia)
13322___Spanish(Chile)
9226____Spanish(Colombia)
5130____Spanish(Costa Rica)
7178____Spanish(Dominican Republic)
12298___Spanish(Ecuador)
17418___Spanish(El Salvador)
4106____Spanish(Guatemala)
18442___Spanish(Honduras)
2058____Spanish(Mexican)
19466___Spanish(Nicaragua)
6154____Spanish(Panama)
15370___Spanish(Paraguay)
10250___Spanish(Peru)
20490___Spanish(Puerto Rico)
3082____Spanish,Spain-Modern Sort
1034____Spanish(Spain - Traditional Sort)
14346___Spanish(Uruguay)
8202____Spanish(Venezuela)
1072____Sutu
1053____Swedish
2077____Swedish(Finland)
1054____Thai
1073____Tsonga
1074____Tswana
1055____Turkish
1058____Ukrainian
1056____Urdu
1075____Venda
1066____Vietnamese
1076____Xhosa
1085____Yiddish
1077____Zulu
2048____default

No comments: