Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Internationalization (v4)
 Auto Detect User Prefer Language
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

stevenzou
Starting Member

China
12 Posts

Posted - 22 November 2001 :  11:23:34  Show Profile  Visit stevenzou's Homepage
Call the function in inc_top.asp

if Application("down") then
if not Instr(request.servervariables("script_name"),"admin_") > 0 then
Response.redirect("down.asp")
end if
end if

'*Add by Steven Zou 2001-11-22
'To detect User's prefer language
'if isEmptyNull(Request.Cookies(strUniqueID & "Lang")) then

if isEmptyNull(strLangPrefCode) then
Call LangDetect()
end if


set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Open strConnString



The Function

<%
'*Add by Steven Zou 2001-11-22
'Generate a page to Auto Detect User Prefer Language when a user first visit
Sub LangDetect()
strURL = Request.QueryString
if strURL <> "" then strURL = "?" & strURL
strURL = Request.ServerVariables("URL") & strURL
%>
<HTML><HEAD>
<TITLE><%=strForumTitle%></TITLE>
<meta http-equiv="refresh" content="0;url=<%=strURL%>">
<%Response.Write "<SCR" & "IPT LANGUAGE=JAVASCRIPT>"%>
<!--
//Program by: Steven Zou(http://www25.brinkster.com/flashmind/forumz/)
//Auto Detect User Prefer Language
var snitzcookietag ='<%=strUniqueID%>Lang';
var blc = navigator.browserLanguage;
var langcode;
switch (blc.substr(0,2)){
case 'en': //English
langcode='1033';
break;
case 'zh': //chinese
langcode='2053';
break;
case 'da': //DANISH
langcode='1030';
break;
case 'de': //DEUTSCH
langcode='1031';
break;
case 'es': //Spanish
langcode='1034';
break;
case 'fi': //Finnish
langcode='1035';
break;
case 'fr': //French
langcode='1036';
break;
case 'it': //Italian
langcode='1040';
break;
case 'nl': //Dutch, Nederlands
langcode='1043';
break;
case 'sv': //Swedish
langcode='1053';
break;
case 'tr': //Turkish
langcode='1055';
break;
default:
langcode='1033'; <%'langcode='< %=strLangDefaultCode% >';%>
}
var resstr= snitzcookietag + '=' + langcode;
var expiration_date = new Date ();
expiration_date.setYear (expiration_date.getYear () + 1);
expiration_date = expiration_date.toGMTString ();
var strURL = escape('<%=strCookieURL%>');
<%'var sitedomain = ".mysite.com"; // Domain wide (must have two dots!!)%>
<%if strSetCookieToForum = 1 then
strCookieTmp ="resstr + ';expires=' + expiration_date + '; ' + 'path=' + strURL + '; '"
'& "+ ';domain=' + escape(sitedomain);"
else
strCookieTmp ="resstr + ';expires=' + expiration_date + '; ' + ';path=/;"
'& " '+ ';domain=' + escape(sitedomain);"
end if%>
document.cookie = <%=strCookieTmp%>;
location.reload();
//-->
<%
response.write "</SCR" & "IPT>" & vbCrLf
%>
</HEAD>
<BODY>
</BODY>
</HTML>
<%
End Sub
%>





Edited by - stevenzou on 22 November 2001 11:25:28

Edited by - stevenzou on 22 November 2001 15:10:10<

Deleted
deleted

4116 Posts

Posted - 22 November 2001 :  12:52:43  Show Profile
Thank you fýr sharing the code. Two problem areas:

1) I use English OS and English browser although I'm in locale Turkey and want to see it in Turkish.
2) Not all languages will be in one installation. My site has Turkish and English only. What if a user from China connects?


Think Pink
Test Site not ready yet | Post v40b03 Patches<
Go to Top of Page

stevenzou
Starting Member

China
12 Posts

Posted - 22 November 2001 :  13:13:08  Show Profile  Visit stevenzou's Homepage
quote:

Thank you fýr sharing the code. Two problem areas:

1) I use English OS and English browser although I'm in locale Turkey and want to see it in Turkish.
2) Not all languages will be in one installation. My site has Turkish and English only. What if a user from China connects?


Think Pink
Test Site not ready yet | Post v40b03 Patches


1) I think no way to detect user needs actually(even though user choose other charset in browser). The function is assume: if user use en-us version bowser, then you should know english. so fetch the english info to user. That's right?

2) if a user connect your site, poperbly chinese charset will be used. If the site don;t support the language, just commented them out, use "default"

<
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.4 seconds. Powered By: Snitz Forums 2000 Version 3.4.07