티스토리 뷰

다국어 사이트를 만들고 사용자 환경에 따라 해당 페이지로 이동하게 만드는데

HTTP_ACCEPT_LANGUAGE를 이용할 수 있다.

 

Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")가 현재 사용중인 언어를 리턴하므로 이 값을 비교해서 각각 다른 페이지로 이동되도록 처리한다.

 

IIS의 Active Server Pages 페이지에서 클라이언트 언어 검색

 

한국어, 일본어, 나머지 영어 사이트로 구성된 경우라면 대략 아래와 비슷하게 될 것이다.

 

<%

lang = LCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"))

 

If InStr(lang, "ko") > 0 Then

    Response.Redirect "/ko/default.asp"

ElseIf InStr(lang, "ja") > 0 Then

    Response.Redirect "/ja/default.asp"

Else

    Response.Redirect "/en/default.asp"

End If

%>

 

여기서 lang = "ko" 이런 식으로 하지 않은 이유는

IE는 Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") 값으로 "ko"를 리턴하지만

파이어폭스 같은 브라우저는 "ko,ko-kr;q=0.8,en-us;q=0.5,en;q=0.3" 처럼 지원하는 언어를 다수로 우선순위까지 더해서 리턴하는 경우도 있기 때문이다.

 

언어별 리턴 값은 아래와 같다.

 

Afrikaans (af)

Afrikaans (af)

Albanian (sq)

Basque (eu)

Bulgarian (bg)

Byelorussian (be)

Catalan (ca)

Chinese (zh)

Chinese/China (zh-cn)

Chinese/Taiwan (zh-tw)

Chinese/Hong Kong (zh-hk)

Chinese/singapore (zh-sg)

Croatian (hr)

Czech (cs)

Danish (da)

Dutch (nl)

Dutch/Belgium (nl-be)

English (en)

English/United Kingdom (en-gb)

English/United Satates (en-us)

English/Australian (en-au)

English/Canada (en-ca)

English/New Zealand (en-nz)

English/Ireland (en-ie)

English/South Africa (en-za)

English/Jamaica (en-jm)

English/Belize (en-bz)

English/Trinidad (en-tt)

Estonian (et)

Faeroese (fo)

Farsi (fa)

Finnish (fi)

French (fr)

French/Belgium (fr-be)

French/France (fr-fr)

French/Switzerland (fr-ch)

French/Canada (fr-ca)

French/Luxembourg (fr-lu)

Gaelic (gd)

Galician (gl)

German (de)

German/Austria (de-at)

German/Germany (de-de)

German/Switzerland (de-ch)

German/Luxembourg (de-lu)

German/Liechtenstein (de-li)

Greek (el)

Hindi (hi)

Hungarian (hu)

Icelandic (is)

Indonesian (id or in)

Irish (ga)

Italian (it)

Italian/Switzerland (it-ch)

Japanese (ja)

Korean (ko)

Latvian (lv)

Lithuanian (lt)

Macedonian (mk)

Malaysian (ms)

Maltese (mt)

Norwegian (no)

Polish (pl)

Portuguese (pt)

Portuguese/Brazil (pt-br)

Rhaeto-Romanic (rm)

Romanian (ro)

Romanian/Moldavia (ro-mo)

Russian (ru)

Russian/Moldavia (ru-mo)

Scots Gaelic (gd)

Serbian (sr)

Slovack (sk)

Slovenian (sl)

Sorbian (sb)

Spanish (es or es-do)

Spanish/Argentina (es-ar)

Spanish/Colombia (es-co)

Spanish/Mexico (es-mx)

Spanish/Spain (es-es)

Spanish/Guatemala (es-gt)

Spanish/Costa Rica (es-cr)

Spanish/Panama (es-pa)

Spanish/Venezuela (es-ve)

Spanish/Peru (es-pe)

Spanish/Ecuador (es-ec)

Spanish/Chile (es-cl)

Spanish/Uruguay (es-uy)

Spanish/Paraguay (es-py)

Spanish/Bolivia (es-bo)

Spanish/El salvador (es-sv)

Spanish/Honduras (es-hn)

Spanish/Nicaragua (es-ni)

Spanish/Puerto Rico (es-pr)

Sutu (sx)

Swedish (sv)

Swedish/Findland (sv-fi)

Thai (ts)

Tswana (tn)

Turkish (tr)

Ukrainian (uk)

Urdu (ur)

Vietnamese (vi)

Xshosa (xh)

Yiddish (ji)

Zulu (zu)

Albanian (sq)

Basque (eu)

Bulgarian (bg)

Byelorussian (be)

Catalan (ca)

Chinese (zh)

Chinese/China (zh-cn)

Chinese/Taiwan (zh-tw)

Chinese/Hong Kong (zh-hk)

Chinese/singapore (zh-sg)

Croatian (hr)

Czech (cs)

Danish (da)

Dutch (nl)

Dutch/Belgium (nl-be)

English (en)

English/United Kingdom (en-gb)

English/United Satates (en-us)

English/Australian (en-au)

English/Canada (en-ca)

English/New Zealand (en-nz)

English/Ireland (en-ie)

English/South Africa (en-za)

English/Jamaica (en-jm)

English/Belize (en-bz)

English/Trinidad (en-tt)

Estonian (et)

Faeroese (fo)

Farsi (fa)

Finnish (fi)

French (fr)

French/Belgium (fr-be)

French/France (fr-fr)

French/Switzerland (fr-ch)

French/Canada (fr-ca)

French/Luxembourg (fr-lu)

Gaelic (gd)

Galician (gl)

German (de)

German/Austria (de-at)

German/Germany (de-de)

German/Switzerland (de-ch)

German/Luxembourg (de-lu)

German/Liechtenstein (de-li)

Greek (el)

Hindi (hi)

Hungarian (hu)

Icelandic (is)

Indonesian (id or in)

Irish (ga)

Italian (it)

Italian/Switzerland (it-ch)

Japanese (ja)

Korean (ko)

Latvian (lv)

Lithuanian (lt)

Macedonian (mk)

Malaysian (ms)

Maltese (mt)

Norwegian (no)

Polish (pl)

Portuguese (pt)

Portuguese/Brazil (pt-br)

Rhaeto-Romanic (rm)

Romanian (ro)

Romanian/Moldavia (ro-mo)

Russian (ru)

Russian/Moldavia (ru-mo)

Scots Gaelic (gd)

Serbian (sr)

Slovack (sk)

Slovenian (sl)

Sorbian (sb)

Spanish (es or es-do)

Spanish/Argentina (es-ar)

Spanish/Colombia (es-co)

Spanish/Mexico (es-mx)

Spanish/Spain (es-es)

Spanish/Guatemala (es-gt)

Spanish/Costa Rica (es-cr)

Spanish/Panama (es-pa)

Spanish/Venezuela (es-ve)

Spanish/Peru (es-pe)

Spanish/Ecuador (es-ec)

Spanish/Chile (es-cl)

Spanish/Uruguay (es-uy)

Spanish/Paraguay (es-py)

Spanish/Bolivia (es-bo)

Spanish/El salvador (es-sv)

Spanish/Honduras (es-hn)

Spanish/Nicaragua (es-ni)

Spanish/Puerto Rico (es-pr)

Sutu (sx)

Swedish (sv)

Swedish/Findland (sv-fi)

Thai (ts)

Tswana (tn)

Turkish (tr)

Ukrainian (uk)

Urdu (ur)

Vietnamese (vi)

Xshosa (xh)

Yiddish (ji)

Zulu (zu)

댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday