views:

23

answers:

1

Hi, I have a big site running under Apache and PHP and in few mounths I should consider to add some different language version of it, but I'm not sure about the right way (or ways).

My problem it isn't the user data, because I can use db tables with different languages (en, de, it, etc.) so I want concentrate my answer on navigation and static content.

For now I can't use gettext because I don't have a dedicated server and I can't reboot it every time I want, but surely will be a future choice.

So my main problems are these:

In the site, I have classical XHTML elements like the menus, lists, div and various static texts in various pages (should be perferct for gettext, but I need a alternative)

The other part of the sites has XHTML elements which are dynamically created via AJAX and jQuery, and here I haven't any idea of what can I do...

So does exists some example I can see in some link to solve it (or some useful tecnique)?

Note:
• The user should be able to change language
• I'd like to avoid multiple divs for different languages in one page, this will be stole me too much bandwith I need, because it could be highly trafficated

A: 

This is explicitly provided for in the XML/XHTML and CSS specs: you want to read up on the lang attribute.

<!-- in english -->
<div lang="en">This is written in English.</div>
<!-- in french, excuse poor french please -->
<div lang="fr">Ceci c'est ecrit en francais.</div>
<!-- in dutch -->
<div lang="nl">Dit is geschreven in het Nederlands.</div>

There's special syntax for CSS to apply styles depending on the lang attribute, too.

thanks for reply, does exist any kind of control on this language selection, like the possibility of language changing?
Vittorio Vittori
I'm not sure I understand what you mean? If you mean is it possible to change lang values with something like JavaScript: http://stackoverflow.com/questions/949341/how-to-obtain-lang-attribute-in-html-using-javascript
I asking you if I can change language like LastFM.com, so with a navigation menu which contains languages list.I'm really confused about multilanguage because I never used it
Vittorio Vittori
Certainly you could: much like you can use a combination of CSS and class names in JavaScript to show/hide content you can do the same with lang attribute.Furthermore you could inspect HTTP headers on the server to select the right default using your server-side language of choice.