Marcos said:
My question is, how do it with php and javascript, but the website it
goes to have many languages.
Thank's.
Marcos
In index.html.en you'd have:
<script type="text/javascript">
var localizationResources = [ 'Hi folks', 'whatever', 'whatever' ];
</script>
In index.html.fr you'd have:
<script type="text/javascript">
var localizationResources = [ 'Bonjour a tous, 'whatever', 'whatever' ];
</script>
In all files you'd have:
<script type="text/javascript">
function greeting()
{
alert(localizationResources[0]);
}
// ...
</script>
The other thing to do is to use PHP to determine the language and
dynamically write the correct client-side script:
<?php
// figure out what language the user is using
if (they are using french) {
$greeting = "french";
} else if (they are using english) {
$greeting = "english";
}
<script type="text/javascript">
alert('<?php echo $greeting ?>');
</script>
I'd prefer the second method because then you don't need to dump all the
localization resources to the client, you only produce the localization
values you need.