Forums

This topic is locked

Buidling multilingual webpages

Posted 19 Aug 2002 10:30:11
1
has voted
19 Aug 2002 10:30:11 Erwin Hendriks posted:
I have to integrate multi-language support into my webpages. These are in English right now, but Dutch and French will follow.
I would like to build dynamic pages so that the user can select his own preferred language.
I was thinking about Prompt-variables with translations in a database-table, each new language will be an extra column in this table.

What is the best way to support multiple languages? Am I on the right track?

Suggestions please!

Nakhba

Replies

Replied 19 Aug 2002 11:12:49
19 Aug 2002 11:12:49 Vince Baker replied:
I have had to do this in the past with English and French.

I solved this by creating a session variable when the user selects the desired language.

You can then have a line of code at the top of each page that decides which recordset you want to filter (which fields).

For example:

<%
Dim strLanguage
strLanguage = Session("Language"
If strLanguage = "French" Then

ENTER RECORDSET HERE

Else

ENTER SECOND LANGUAGE RECORDSET REQUEST HERE

End IF
%>

Replied 19 Aug 2002 11:14:48
19 Aug 2002 11:14:48 Vince Baker replied:
Forgot to mention:

WHere I wrote ENTER RECORDSET HERE I meant to say recordset sql.

Create a variable ie strSQL and this will ensure your dynamic fields are coming will correctly be named, just the sql calling from a different table.

Vince

Replied 19 Aug 2002 12:02:28
19 Aug 2002 12:02:28 Erwin Hendriks replied:
Thanks Vince,

This is what I intended to do. Thanks for your reaction, I'm on my way!

Nakhba
Replied 19 Aug 2002 21:45:35
19 Aug 2002 21:45:35 David Behan replied:
The way I would do this is using 2 different fields in a database structured like this:

PAGE_ID
PAGE_NAME
PAGE_ENGLISH
PAGE_FRENCH

On your page have:

'**************************
chosen_language = Request.Cookies("chosen_language"
'**************************

Then, on your page you either want to display the english text from field PAGE_ENGLISH or the french text from PAGE_FRENCH. Do this by:

'**************************
SELECT CASE chosen_language
CASE "english"
body_text = rsPageDetails.Fields.Item("PAGE_ENGLISH".Value

CASE "french"
body_text = rsPageDetails.Fields.Item("PAGE_FRENCH".Value

Case Else 'If you want default language to be english
body_text = rsPageDetails.Fields.Item("PAGE_ENGLISH".Value

End Select
'**************************

All that should appear at the top of your page before your html and after your recordset has been filtered. In the middle of your html where you want your text in the chosen language to appear you should have:

'**************************
<% = body_text %>
'**************************

Now, one more thing to do. Give the user the option of setting their preferred language. By using cookies instead of session cookies, you will impress the user by remembering their language of preference when they return.

Have two flags or something like that on your site and point them to change_language.asp with a variable in the address so if you chose either below it would go to the particular address:

ENGLISH FLAG LINK: change_language.asp?lang=english
FRENCH FLAG LINK: change_language.asp?lang=french

On change_language.asp have the following:

'**************************
Response.Cookies("chosen_language" = Request.QueryString("lang"
Response.Cookies("chosen_language".Expires = date + 365
Response.Redirect(HTTP_REFERRER)
'**************************

That's it. You can make this work with 10 different languages if you want. The same principle would apply. I didn't test any of that code so don't mind if there is a spelling mistake or simple error. It will give you a heads up and point you in the right direction. I better bookmark this for myself cause I plan to do this with a site shortly and hadn't actually thought the process through until now. Once again, I advise using cookies and not the session cookie. Using the above scripts, the user, on returning to your web site will be presented with the language they chose last time round. I went to a site that allowed you to change to about 20 different languages and visited the site a number of times in a couple of days. Everytime I went to it, I had to reset the language to my preferred and that really pissed me off.

Enjoy!!!


Dave
<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>



_________________________
WinXP : IIS 5.1 : StudioMX : ASP : VBScript
www.clicksdesign.com
Replied 23 Aug 2002 12:07:20
23 Aug 2002 12:07:20 Daniel Beck replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
The way I would do this is using 2 different fields in a database structured like this:

PAGE_ID
PAGE_NAME
PAGE_ENGLISH
PAGE_FRENCH

On your page have:

'**************************
chosen_language = Request.Cookies("chosen_language"
'**************************

Then, on your page you either want to display the english text from field PAGE_ENGLISH or the french text from PAGE_FRENCH. Do this by:

'**************************
SELECT CASE chosen_language
CASE "english"
body_text = rsPageDetails.Fields.Item("PAGE_ENGLISH".Value

CASE "french"
body_text = rsPageDetails.Fields.Item("PAGE_FRENCH".Value

Case Else 'If you want default language to be english
body_text = rsPageDetails.Fields.Item("PAGE_ENGLISH".Value

End Select
'**************************

All that should appear at the top of your page before your html and after your recordset has been filtered. In the middle of your html where you want your text in the chosen language to appear you should have:

'**************************
&lt;% = body_text %&gt;
'**************************

Now, one more thing to do. Give the user the option of setting their preferred language. By using cookies instead of session cookies, you will impress the user by remembering their language of preference when they return.

Have two flags or something like that on your site and point them to change_language.asp with a variable in the address so if you chose either below it would go to the particular address:

ENGLISH FLAG LINK: change_language.asp?lang=english
FRENCH FLAG LINK: change_language.asp?lang=french

On change_language.asp have the following:

'**************************
Response.Cookies("chosen_language" = Request.QueryString("lang"
Response.Cookies("chosen_language".Expires = date + 365
Response.Redirect(HTTP_REFERRER)
'**************************

That's it. You can make this work with 10 different languages if you want. The same principle would apply. I didn't test any of that code so don't mind if there is a spelling mistake or simple error. It will give you a heads up and point you in the right direction. I better bookmark this for myself cause I plan to do this with a site shortly and hadn't actually thought the process through until now. Once again, I advise using cookies and not the session cookie. Using the above scripts, the user, on returning to your web site will be presented with the language they chose last time round. I went to a site that allowed you to change to about 20 different languages and visited the site a number of times in a couple of days. Everytime I went to it, I had to reset the language to my preferred and that really pissed me off.

Enjoy!!!


Dave
<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>



_________________________
WinXP : IIS 5.1 : StudioMX : ASP : VBScript
www.clicksdesign.com
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Dave... u are a genius..... it works perfektly

Replied 05 Sep 2002 09:32:01
05 Sep 2002 09:32:01 Erwin Hendriks replied:
Thanks for all the contributions to this topic!

Nakhba

Reply to this topic