文章編號: 229690 - 上次校閱: 2005年4月29日 - 版次: 6.3

如何設定 ASP 地區設定識別碼,每個瀏覽器的語言設定

系統提示本文適用於您使用的作業系統之外的作業系統。與您不相關的文章內容已停用。

在此頁中

全部展開 | 全部摺疊

結論

當您建立動態伺服器網頁 (ASP) 應用程式的多重 internation 站台存取時,它是很有幫助修改地區設定設定值,以 VBScript 日期、 時間、 貨幣及的話 forth 格式傳回使用者的位置正確的格式。

其他相關資訊

下列副程式動態設定地區設定識別碼對該 ASP 應用程式 (Session.LCID),依據使用者的瀏覽器所提供的語言設定值來:
<SCRIPT Runat=Server Language=VBScript>
Sub SetLCID()
  Dim strAcceptLanguage
  Dim strLCID
  Dim strPos
  
  strAcceptLanguage = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")

  strPos = InStr(1, strAcceptLanguage, ",")
  If strPos > 0 Then
    strAcceptLanguage = Left(strAcceptLanguage, strPos - 1)
  End If
   
  Select Case LCase(strAcceptLanguage)
    Case "af"
      strLCID = 1078  ' Afrikaans 
    Case "sq"
      strLCID = 1052  ' Albanian 
    Case "ar-sa"
      strLCID = 1025  ' Arabic(Saudi Arabia) 
    Case "ar-iq"
      strLCID = 2049  ' Arabic(Iraq) 
    Case "ar-eg"
      strLCID = 3073  ' Arabic(Egypt) 
    Case "ar-ly"
      strLCID = 4097  ' Arabic(Libya) 
    Case "ar-dz"
      strLCID = 5121  ' Arabic(Algeria) 
    Case "ar-ma"
      strLCID = 6145  ' Arabic(Morocco) 
    Case "ar-tn"
      strLCID = 7169  ' Arabic(Tunisia) 
    Case "ar-om"
      strLCID = 8193  ' Arabic(Oman) 
    Case "ar-ye"
      strLCID = 9217  ' Arabic(Yemen) 
    Case "ar-sy"
      strLCID = 10241 ' Arabic(Syria) 
    Case "ar-jo"
      strLCID = 11265 ' Arabic(Jordan) 
    Case "ar-lb"
      strLCID = 12289 ' Arabic(Lebanon) 
    Case "ar-kw"
      strLCID = 13313 ' Arabic(Kuwait) 
    Case "ar-ae"
      strLCID = 14337 ' Arabic(U.A.E.) 
    Case "ar-bh"
      strLCID = 15361 ' Arabic(Bahrain) 
    Case "ar-qa"
      strLCID = 16385 ' Arabic(Qatar) 
    Case "eu"
      strLCID = 1069  ' Basque 
    Case "bg"
      strLCID = 1026  ' Bulgarian 
    Case "be"
      strLCID = 1059  ' Belarusian 
    Case "ca"
      strLCID = 1027  ' Catalan 
    Case "zh-tw"
      strLCID = 1028  ' Chinese(Taiwan) 
    Case "zh-cn"
      strLCID = 2052  ' Chinese(PRC) 
    Case "zh-hk"
      strLCID = 3076  ' Chinese(Hong Kong) 
    Case "zh-sg"
      strLCID = 4100  ' Chinese(Singapore) 
    Case "hr"
      strLCID = 1050  ' Croatian 
    Case "cs"
      strLCID = 1029  ' Czech 
    Case "da"
      strLCID = 1030  ' Danish 
    Case "nl"
      strLCID = 1043  ' Dutch(Standard) 
    Case "nl-be"
      strLCID = 2067  ' Dutch(Belgian) 
    Case "en"
      strLCID = 9     ' English 
    Case "en-us"
      strLCID = 1033  ' English(United States) 
    Case "en-gb"
      strLCID = 2057  ' English(British) 
    Case "en-au"
      strLCID = 3081  ' English(Australian) 
    Case "en-ca"
      strLCID = 4105  ' English(Canadian) 
    Case "en-nz"
      strLCID = 5129  ' English(New Zealand) 
    Case "en-ie"
      strLCID = 6153  ' English(Ireland) 
    Case "en-za"
      strLCID = 7177  ' English(South Africa) 
    Case "en-jm"
      strLCID = 8201  ' English(Jamaica) 
     Case "en-ca"
      strLCID = 9225  &apos; English(Caribbean)"?> 
    Case "en-bz"
      strLCID = 10249 ' English(Belize) 
    Case "en-tt"
      strLCID = 11273 ' English(Trinidad) 
    Case "et"
      strLCID = 1061  ' Estonian 
    Case "fo"
      strLCID = 1080  ' Faeroese 
    Case "fa"
      strLCID = 1065  ' Farsi 
    Case "fi"
      strLCID = 1035  ' Finnish 
    Case "fr"
      strLCID = 1036  ' French(Standard) 
    Case "fr-be"
      strLCID = 2060  ' French(Belgian) 
    Case "fr-ca"
      strLCID = 3084  ' French(Canadian) 
    Case "fr-ch"
      strLCID = 4108  ' French(Swiss) 
    Case "fr-lu"
      strLCID = 5132  ' French(Luxembourg) 
    Case "mk"
      strLCID = 1071  ' Macedonian (FYROM) 
    Case "gd"
      strLCID = 1084  ' Gaelic(Scots) 
    Case "de"
      strLCID = 1031  ' German(Standard) 
    Case "de-ch"
      strLCID = 2055  ' German(Swiss) 
    Case "de-at"
      strLCID = 3079  ' German(Austrian) 
    Case "de-lu"
      strLCID = 4103  ' German(Luxembourg) 
    Case "de-li"
      strLCID = 5127  ' German(Liechtenstein) 
    Case "el"
      strLCID = 1032  ' Greek 
    Case "he"
      strLCID = 1037  ' Hebrew 
    Case "hi"
      strLCID = 1081  ' Hindi 
    Case "hu"
      strLCID = 1038  ' Hungarian 
    Case "is"
      strLCID = 1039  ' Icelandic 
    Case "in"
      strLCID = 1057  ' Indonesian 
    Case "it"
      strLCID = 1040  ' Italian(Standard) 
    Case "it-ch"
      strLCID = 2064  ' Italian(Swiss) 
    Case "ja"
      strLCID = 1041  ' Japanese 
    Case "ko"
      strLCID = 1042  ' Korean 
    Case "ko"
      strLCID = 2066  ' Korean(Johab) 
    Case "lv"
      strLCID = 1062  ' Latvian 
    Case "lt"
      strLCID = 1063  ' Lithuanian 
    Case "ms"
      strLCID = 1086  ' Malaysian 
    Case "mt"
      strLCID = 1082  ' Maltese 
    Case "no"
      strLCID = 1044  ' Norwegian(Bokmal) 
    Case "no"
      strLCID = 2068  ' Norwegian(Nynorsk) 
    Case "pl"
      strLCID = 1045  ' Polish 
    Case "pt-br"
      strLCID = 1046  ' Portuguese(Brazil) 
    Case "pt"
      strLCID = 2070  ' Portuguese(Portugal) 
    Case "rm"
      strLCID = 1047  ' Rhaeto-Romanic 
    Case "ro"
      strLCID = 1048  ' Romanian 
    Case "ro-mo"
      strLCID = 2072  ' Romanian(Moldavia) 
    Case "ru"
      strLCID = 1049  ' Russian 
    Case "ru-mo"
      strLCID = 2073  ' Russian(Moldavia) 
    Case "sz"
      strLCID = 1083  ' Sami(Lappish) 
    Case "sr"
      strLCID = 3098  ' Serbian(Cyrillic) 
    Case "sr"
      strLCID = 2074  ' Serbian(Latin) 
    Case "sk"
      strLCID = 1051  ' Slovak 
    Case "sl"
      strLCID = 1060  ' Slovenian 
    Case "sb"
      strLCID = 1070  ' Sorbian 
    Case "es"
      strLCID = 1034  ' Spanish(Spain - Traditional Sort) 
    Case "es-mx"
      strLCID = 2058  ' Spanish(Mexican) 
    Case "es-gt"
      strLCID = 4106  ' Spanish(Guatemala) 
    Case "es-cr"
      strLCID = 5130  ' Spanish(Costa Rica) 
    Case "es-pa"
      strLCID = 6154  ' Spanish(Panama) 
    Case "es-do"
      strLCID = 7178  ' Spanish(Dominican Republic) 
    Case "es-ve"
      strLCID = 8202  ' Spanish(Venezuela) 
    Case "es-co"
      strLCID = 9226  ' Spanish(Colombia) 
    Case "es-pe"
      strLCID = 10250 ' Spanish(Peru) 
    Case "es-ar"
      strLCID = 11274 ' Spanish(Argentina) 
    Case "es-ec"
      strLCID = 12298 ' Spanish(Ecuador) 
    Case "es-c"
      strLCID = 13322 ' Spanish(Chile) 
    Case "es-uy"
      strLCID = 14346 ' Spanish(Uruguay) 
    Case "es-py"
      strLCID = 15370 ' Spanish(Paraguay) 
    Case "es-bo"
      strLCID = 16394 ' Spanish(Bolivia) 
    Case "es-sv"
      strLCID = 17418 ' Spanish(El Salvador) 
    Case "es-hn"
      strLCID = 18442 ' Spanish(Honduras) 
    Case "es-ni"
      strLCID = 19466 ' Spanish(Nicaragua) 
    Case "es-pr"
      strLCID = 20490 ' Spanish(Puerto Rico) 
    Case "sx"
      strLCID = 1072  ' Sutu 
    Case "sv"
      strLCID = 1053  ' Swedish 
    Case "sv-fi"
      strLCID = 2077  ' Swedish(Finland) 
    Case "th"
      strLCID = 1054  ' Thai 
    Case "ts"
      strLCID = 1073  ' Tsonga 
    Case "tn"
      strLCID = 1074  ' Tswana 
    Case "tr"
      strLCID = 1055  ' Turkish 
    Case "uk"
      strLCID = 1058  ' Ukrainian 
    Case "ur"
      strLCID = 1056  ' Urdu 
    Case "ve"
      strLCID = 1075  ' Venda 
    Case "vi"
      strLCID = 1066  ' Vietnamese 
    Case "xh"
      strLCID = 1076  ' Xhosa 
    Case "ji"
      strLCID = 1085  ' Yiddish 
    Case "zu"
      strLCID = 1077  ' Zulu 
    Case Else
      strLCID = 2048  ' default
  End Select 

  Session.LCID = strLCID
End Sub
</SCRIPT>
				

範例 ASP 網頁

下列範例程式碼可能用來示範地區設定變更。 若要示範所做的變更,使用下列程式碼建立 ASP 網頁],並在瀏覽器中檢視]。在 [網際網路選項] (或 [喜好設定])] 區段修改您的 語言 設定,並重新整理 ASP 網頁。

注意: [SetLCID() 程式碼範例被放在稱為 setlcid.inc 的包含檔案。
<%@ Language=VBScript %>
<HTML>
<BODY>

<!--#include file=setlcid.inc -->

<%
SetLCID   'Set the Locale ID per the browser

Response.Write "Date/Time Formats"
Response.Write "<p>Date = " & Date()
Response.Write "<br>Month = " & Month(Date())
Response.Write "<br>Day = " & Day(Date())
Response.Write "<br>Year = " & Year(Date())
Response.Write "<br>Time = " & Time()

Response.Write "<p>Currency Formats"
Response.Write "<p>" & FormatCurrency(1.05, 2)
Response.Write "<br>" & FormatNumber(1000000,2)
Response.Write "<br>" & FormatNumber(-1000000,2)

%>
</BODY>
</HTML>
				

這篇文章中的資訊適用於:
  • Microsoft Active Server Pages 4.0
  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Services 5.0
關鍵字:?
kbmt kbcodesnippet kbhowto kblocalization KB229690 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:229690? (http://support.microsoft.com/kb/229690/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。