PDA

View Full Version : Need Help!!! How to support multi-lingual in Delphi5 and Web Page?


Christina
May 21st, 2001, 08:02 AM
I need some information with regards to the above subject.. thanks!

MishY
May 21st, 2001, 09:39 AM
Hiya Christina and welcome to CTH :)

Your question is better suited to your Website & Graphics forum which I am going to transfer your topic to now. To go to your topic Click Here (http://www.cybertechhelp.com/cgi-bin/ultimatebb.cgi?ubb=forum&f=11)

MishY

Christina
May 21st, 2001, 10:14 AM
Thanks Mishy... wish someone could help me here... i really need it... :(

Steven.Bentley
May 21st, 2001, 10:46 AM
Hi Christina :)

I've not had any experience with Delphi, but for the web page angle, JavaScript can tell you what the user's browser language is set to. There are a number of potential values that it can return:

af Afrikaans
ar-ae Arabic(U.A.E.)
ar-bh Arabic(Bahrain)
ar-dz Arabic(Algeria)
ar-eg Arabic(Egypt)
ar-iq Arabic(Iraq)
ar-jo Arabic(Jordan)
ar-kw Arabic(Kuwait)
ar-lb Arabic(Lebanon)
ar-ly Arabic(Libya)
ar-ma Arabic(Morocco)
ar-om Arabic(Oman)
ar-qa Arabic(Qatar)
ar-sa Arabic(Saudi Arabia)
ar-sy Arabic(Syria)
ar-tn Arabic(Tunisia)
ar-ye Arabic(Yemen)
be Belarusian
bg Bulgarian
ca Catalan
cs Czech
da Danish
de German(Standard)
de-at German(Austrian)
de-ch German(Swiss)
de-li German(Liechtenstein)
de-lu German(Luxembourg)
el Greek
en English
en English(Caribbean)
en-au English(Australian)
en-bz English(Belize)
en-ca English(Canadian)
en-gb English(British)
en-ie English(Ireland)
en-jm English(Jamaica)
en-nz English(New Zealand)
en-tt English(Trinidad)
en-us English(United States)
en-za English(South Africa)
es Spanish(Spain - Modern Sort)
es Spanish(Spain - Traditional Sort)
es-ar Spanish(Argentina)
es-bo Spanish(Bolivia)
es-cl Spanish(Chile)
es-co Spanish(Colombia)
es-cr Spanish(Costa Rica)
es-do Spanish(Dominican Republic)
es-ec Spanish(Ecuador)
es-gt Spanish(Guatemala)
es-hn Spanish(Honduras)
es-mx Spanish(Mexican)
es-ni Spanish(Nicaragua)
es-pa Spanish(Panama)
es-pe Spanish(Peru)
es-pr Spanish(Puerto Rico)
es-py Spanish(Paraguay)
es-sv Spanish(El Salvador)
es-uy Spanish(Uruguay)
es-ve Spanish(Venezuela)
et Estonian
eu Basque
fa Farsi
fi Finnish
fo Faeroese
fr French(Standard)
fr-be French(Belgian)
fr-ca French(Canadian)
fr-ch French(Swiss)
fr-lu French(Luxembourg)
gd Gaelic(Scots)
gd-ie Gaelic(Irish)
he Hebrew
hi Hindi
hr Croatian
hu Hungarian
in Indonesian
is Icelandic
it Italian(Standard)
it-ch Italian(Swiss)
ja Japanese
ji Yiddish
ko Korean
ko Korean(Johab)
lt Lithuanian
lv Latvian
mk Macedonian
ms Malaysian
mt Maltese
nl Dutch(Standard)
nl-be Dutch(Belgian)
no Norwegian(Bokmal)
no Norwegian(Nynorsk)
pl Polish
pt Portuguese(Standard)
pt-br Portuguese(Brazilian)
rm Rhaeto-Romanic
ro Romanian
ro-mo Romanian(Moldavia)
ru Russian
ru-mo Russian(Moldavia)
sb Sorbian
sk Slovak
sl Slovenian
sq Albanian
sr Serbian(Cyrillic)
sr Serbian(Latin)
sv Swedish
sv-fi Swedish(Finland)
sx Sutu
sz Sami(Lappish)
th Thai
tn Tswana
tr Turkish
ts Tsonga
uk Ukrainian
ur Urdu
ve Venda
vi Vietnamese
xh Xhosa
zh-cn Chinese(PRC)
zh-hk Chinese(Hong Kong)
zh-sg Chinese(Singapore)
zh-tw Chinese(Taiwan)
zu Zulu


Knowing that, you can then use if statements to redirect the user to a localised version of the site. You'll notice that there are several versions of each language. You're not going to want to do a different version of the site for each one, you would do a different one the main language.

<html>
<head>
<title>
Detecting Language
</title>
</head>
<body>
<script>

//set up default language as English. This is what they'll get if there isn't a localised version for what the browser says they're using.

language="en"

//check what language the browser is set to and store in language. IE and NS use different property names for this.

if(navigator.language){
language=navigator.language
}

if(navigator.systemLanguage){
language=navigator.systemLanguage
}

//use .match so we don't need to check for en-gb en-nz etc seperately, just check for en. redirect as appropriate.

if (language.match("en")){
location.replace("english.htm")
}

if (language.match("fr")){
location.replace("french.htm")
}

if (language.match("ar")){
location.replace("arabic.htm")
}

if (language.match("de")){
location.replace("german.htm")
}

if (language.match("es")){
location.replace("spanish.htm")
}

if (language.match("it")){
location.replace("italian.htm")
}

</script>

<noscript>
links to each version go here, for older browsers
</noscript>

</body>
</html>

Christina
May 23rd, 2001, 03:21 AM
Hi Steven,

thanks for the info... but it seems that your suggestion can only handle one language at a time in one page... do you have any idea on how display 2 diff languages at the same time in one page? thanks!!! ;)

Steven.Bentley
May 23rd, 2001, 10:38 AM
It's possible but it means having multiple copies of the same information in one file, so it will take a while to download.

If you swap the location.replace() statements to document.write() statements you can do something like this:


if (language.match("en")){
document.write("<h1>Hello</h1>")
}
if (language.match("fr")){
document.write("<h1>Bonjour</h1>")
}


that will display Hello to English language browsers and Bonjour to French language ones.

Christina
May 23rd, 2001, 11:46 AM
Hi again Steven!

I have a follow question... what if the data is dynamic? i mean the data is from the database... let us say the db stores both chinese and french... would it be possible for both chinese and french display at the same time?

thanks again! :)

Steven.Bentley
May 23rd, 2001, 01:38 PM
It really depends on what kind of database it is and what kind of structure you're using. In theory all it would need would be for the SQL query to be tweaked to retrieve both versions.

If you can give a brief outline of the table structure, the fields etc you're using, that would help.

It would also help to know what kind of server side scripting you're using, PHP, PERL etc, or ASP if you really must :D

Christina
May 24th, 2001, 01:54 AM
Hi Steven!

Basically the database is ORACLE8i... and the table structure would simply have two fields... let us say one for NAME_CHI, and NAME_FR both have varchar2(100).

For the webpage we used JSP.

thanks!!!

Steven.Bentley
May 24th, 2001, 06:08 PM
OK I don't know JSP, but I'd guess that it has some facilities to detect the language in the same way that JavaScript can. You would have to detect it from JSP because the page would be put together on the server, before any JavaScript runs.

When you have that value, you can pass that into an SQL query.