Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Websites in Multiple Languages 1

Status
Not open for further replies.

gmail2

Programmer
Jun 15, 2005
987
IE
We have a website which is used for remote access for users. It loads in whichever language is top of the user's preference - how is this done? Is it because it uses Java as I've noticed that Java Web Start can do this also. Or is there a way of doing this in good old fashioned HTML?
 
Push the pages through the google translator

for instance



that page is dynamically generated from a MySQL database (in English). Then using htaccess the second page is sent through the Google translator.



<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Buy Languedoc wines in the UK
 
I don't think that's how this one works - it's all the same page. However, your suggestion is good none the less. But when I click on the french link above, I just get sent back to the English link again. Even if I add French into my languages and move it to the top of the priority list. Also, how are you using htaccess to control this? Have you got a separate /french folder and then somehow use htaccess to pass it through google first?
 
No.
The htaccess file simply does a url rewrite when it detects the "-fr" on the end of the URL
It sends the page to the Google Translator

Code:
#Language translations via Google translate
RewriteRule ^(.*)-fr$ [URL unfurl="true"]http://www.google.com/translate_c?hl=fr&sl=en&u=http://www.targetgroup.co.uk/tcms/$1[/URL] [r,nc]

There are problems with this method. It's just me playing around at the moment. It was something I found out about over the weekend.

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Buy Languedoc wines in the UK
 
I allow the users to set the language using a session variable (I'm using php for this particular site). I have translated the content of each page and store this in a table within a mySQL database (along with the english versions of the same page). My server-side query returns data from the foreign language table and if there is no translation available, it defaults to using english.

The key here is that everything happens server-side... no javascript is required.

Another solution is to place a set of language specific includes in a directory... and include the appropriate include based on the language chosen in the session variable.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Yea I knew you could do it thru MySQL or another db but I just thought there might have been a client side way of doing it. I rekon that the site I've seen it on must be somehow doing it thru Java 'cos I know that Java WebStart seems to be able to display menu's etc in the non-unicdoe language now.

Oh, foamcow - German ain't working either !!!!!
 
It is.
There is obviously something amiss with this method.

I checked the French again and they all worked except the page I linked to.

I wonder if there is a limit on the number of times Google will let you hit the translator?

Whatever, it seems that it's not a reliable method.

The best way is to get "proper" translations done and do what Jeff is doing or create language files and have your site/app pull the right text depending on the language selected.

There is no client side way to do the translations if that's what you mean. It would mean every user having translation software on their machine!

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Buy Languedoc wines in the UK
 
Now that I think about it ... yea you're right !! I was thinking along the lines that maybe you could put chr(0127) instead of the actual characters (but maybe something not quiet so bloated) ... but of course the more I think about it the more I realise I'm wrong ... it's words that need to be translated, not letters and characters !! Anyway, it was just a curiosity as much as anything else, if ther had been some way I might have tried it out. I already knew about doing it thru a db, just thought there might be a different way.

On an unrelated note, I just had a quick look at your site foamcow - I really like it. You've got alot of creative talent, wish I had. Programming's no problem, but coming up with design ideas I always fall at the first hurdly. Anyway, hope you don't mind me asking - that wine website ... how did you handle the e-commerce side? Does it use a 3rd party service or ? I'm starting a website for a publishing company and they'd like an online bookstore. Again, hope you don't mind me asking, just that I saw it and I thought I'd ask

Cheers

ps 1 + 2 + 3 x 4 = 24 :)
 
The Wine site was built using ZenCart.
Though if I did another ecommerce site I probably wouldn't use it.
It took a long time to hammer it into shape and even longer to get the damned HSBC payment system integrated into it.

Lots of people have problems with it and I seem to have become the HSBC/ZenCart expert as I get lots of requests for help and quite a few downloads of the module from my site.

Take a look at Karova - VERY nice ecommerce solution, fully hosted, standards compliant and despite what you may think it's bloody cheap too!


<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Buy Languedoc wines in the UK
 
It's not ??? Is this one of those funny rules where multiplication comes before addition !?!?

Anyway, have a look at babelfish.altavista.com - it somehow uses multiple languages. if you add say, French into your languages in IE and move it to the top, it'll display in french. Of course having said that, it is a translation website so I guess they do have the edge on somebody like us !!
 
Not really what you asked, but...

I have a site in which some pages are available in both English and Italian. The way I did it was to put all the english pages in an /eng/ subdirectory, and their italian counterparts in /ita/. So if you're looking at


the SSI program that generates the side menu knows to do it in English (because of the directory). It can also look to see if there's a file called /ita/index.shtml and, if there is, include a link to it in the sidebar. Potentially, the same technique could be used for multiple languages (maybe it will be if I can find some more translators... ).

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
But in babelfish somehow they manage to display the same page in a different language - depending on which language is highest on your pirority list in IE. How'd they do this? Although like I said, I guess they do have the edge seing that they're a translation website anyway.
 
I think the browser sends that language list in the HTTP request as an [tt]Accept-language[/tt] header. So it's simple for a server-side program to read this and serve up an appropriate language version (provided it has one to serve, of course).

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
ah ... that makes sense. I think thinking that you'd have to be client side to read the language but of course what you just said makes perfect sense. I think a big shiny star is in order for that :)
 
We had a site that was supposed to offer information in English, German, Spanish, and French. For the pages, I included DIV containers with each language. Then, the user could click on a link that would invisibilate the current container and revisibilate the desired language container.

This meant we included all translations in the code, but we also had complete control over the translation (we could send it all over to various reps for "polishing").

In the code:

Code:
<div id="EngTran" class="EngTran">The S62 connects easily to a Windows computer USB port.</div>
<div id="FreTran" class="FreTran">Le S62 connecte facilement à un Windows port de USB informatique.</div>
<div id="EspTran" class="EspTran">El S62 conecta fácilmente a un puerto de la computadora de Windows USB.</div>
<div id="DeuTran" class="DeuTran">Der S62 verbindet leicht zu einem Fenster Computer USB Hafen.</div>
<div id="NTxTran" class="NTxTran"></div>

and then the chooser link was

Code:
<h6>Choose text display language:<br /><a href="#" onClick="javascript:ChooseEnglish();return 0;">English</a> &bull; <a href="#" onClick="javascript:ChooseFrench();return 0;">French</a> &bull; <a href="#" onClick="javascript:ChooseSpanish();return 0;">Spanish</a> &bull; <a href="#" onClick="javascript:ChooseGerman();return 0;">German</a> &bull; <a href="#" onClick="javascript:ChooseNoText();return 0;">no text</a></h6>

And then in the JS file...

Code:
    function ChooseFrench() // Turns on the French text
      {
        // Turn all other languages off
           TurnEverythingOff();
        // Turn French on
        // document.getElementById('FreTran').style.display = 'inline';
      }

This is the example for French -- obvioulsy the other languages had their own functions.

I'd send you a link to the version online, but it was eventually decided that until the languages are better translated, they would rather only see English.

Maybe something like that would help you?

Cheers,

[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Wow - that's a really good idea actually isn't it. Yea, I understand the principles of the code, would be interesting to see it in action though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top