Using the Locale Identifier (LCID) (2)

Source: Internet
Author: User
Tags locale locale setting
In Part 1 we discussed how the WEB server's regional settings (editable by the Administrator through the control Panel ' s R egional Options icon) affect the output of VBScript ' s Format functions. In this part we'll look at the using the "Session.LCID property to" change this default locale on a user-by-user (or Web page-by -web page) basis! <br>
<br>
Setting the Locale ID on a user-by-user basis:<br>
While the default locale setting dictates is the output of the Format functions, what if you want to have the output differ B ased on the person visiting the page? (Perhaps run a site where the user can customize the output or content presented, a site like me Yahoo! or any of the Other customizable portals.) One option is to use the ' LCID ' of the ' Session object ' (LCID stands for Locale Identifier). For example, your can specify the Locale for a particular user to is Estonian by using the following code: <br>
<br>
Session.LCID = 1061 ' Estonian Locale ID <br>
<br>
<br>
Now, your may is wondering how to the world I knew that Estonian's LCID was 1061. The simplest way is to consult Microsoft's LCID table. This handy table contains a listing of the various locales and their associated IDs. By simply changing this locale ID, the output for the VBScript Format functions'll change for the particular user. The Using this property can be automatically have the Format functions ' output change based on the user ' LCID. <br>
<br>
One thing to being wary of is currency issues. For example, if I am running an 中文版 ecommerce site and have my Web server ' s regional Settings set to english-united States by default, I could have some code that looks like this: <br>
<br>
Shoes Cost: <%=formatcurrency (45.56)%> <br>
<br>
<br>
Since, in this hypothetical example, I run a ecommerce site in the "US" I mean that's cost for the shoes are and cents. However, if set a user ' s Session.LCID property to, say, 2057 (English-united Kingdom), the shoes would appear to cost 45 . pounds! Therefore, if you are on altering the LCID settings I strongly encourage the FormatCurrency function Or, if you did, that instead of passing a hard-coded value into the function of the "in" result of some currency Exchan GE rate calculation function: <br>
<br>
Shoes Cost: <%=formatcurrency (Convertfromdollars (45.56))%> <br>
<br>
<br>
The Convertfromdollar function would then consult the Session.LCID property to determine what currency we were We dollars to. (for your would then need to use some component like Iiscartex to perform the actual currency.) <br>
<br>
Setting the Locale ID on a page-by-page basis:<br>
You can also specify the LCID to a entire ASP page instead of on a user-by-user basis. For example, if your had a Web page on your site then, for some reason, your wanted to always use the Hebrew formatting E (LCID 1037) your could do via the @LCID directive. As with the other ASP directives (@LANGUAGE, @ENABLESESSIONSTATE, etc.), the @LCID directive must appear before any ASP or HTML code. For example, to set a ASP page ' LCID to 1037 (Hebrew), we could use the following code: <br>
<br>
<% @LCID =1037%> <br>
<br>
<br>
Or, if we wished to specify multiple directives, we could do: <br>
<br>
<% @LANGUAGE = "VBSCRIPT" lcid=1037%> <br>
<br>
<br>
That's all there are to it! <br>
<br>
Conclusion:<br>
In this article we examined how to set the default locale settings through the regional Options icon in the Web server ' s C Ontrol Panel. This locale default determines how VBScript ' s Format functions produce their output. Any locale setting can is fully customized for a very the unique look and feel for representing, numbers, and Currencies. ASP also provides a Locale ID on both a user-by-user basis and a page-by-page basis. To specify a locale ID (LCID) for a particular user, set the Session.LCID property to the appropriate numeric ID. To set the LCID is particular ASP page, use the @LCID directive. (For a listing of the various LCIDs and their respective values, check out the LCID table.) <br>
<br>
Happy programming! <br>
<br>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.