By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,481 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,481 IT Pros & Developers. It's quick & easy.

Translate JS Messages

P: n/a

I need to translate the messages of mine scripts, as I can make
professionally this working with the pair php and javascript?

Thank`s
--
Marcos.
http://www.linuxhard.org
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Marcos wrote on 01 mrt 2005 in comp.lang.javascript:
I need to translate the messages of mine scripts, as I can make
professionally this working with the pair php and javascript?


Translate as in:

alert('Hi folks')

to

alert('Bonjour a tous')

?

If so what is your question?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2

P: n/a
My question is, how do it with php and javascript, but the website it goes
to have many languages.

Thank's.

Marcos

Em 01 Mar 2005 14:18:09 GMT, Evertjan. <ex**************@interxnl.net>
escreveu:
Translate as in

Jul 23 '05 #3

P: n/a
Marcos wrote:
My question is, how do it with php and javascript, but the website it goes
to have many languages.


The same way you translate the rest of your content - presumably through
gettext.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #4

P: n/a
"Marcos" <me@privacy.net> wrote in message
news:op**************@rogerio.network...
My question is, how do it with php and javascript, but the website it
goes to have many languages.

Thank's.

Marcos

Em 01 Mar 2005 14:18:09 GMT, Evertjan. <ex**************@interxnl.net>
escreveu:
Translate as in


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.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #5

P: n/a
You they had helped very!

Thank's.

Em Tue, 01 Mar 2005 20:01:37 GMT, Grant Wagner
<gw*****@agricoreunited.com> escreveu:
"Marcos" <me@privacy.net> wrote in message
news:op**************@rogerio.network...
My question is, how do it with php and javascript, but the website it
goes to have many languages.

Thank's.

Marcos

Em 01 Mar 2005 14:18:09 GMT, Evertjan. <ex**************@interxnl.net>
escreveu:
Translate as in


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.


--
Marcos.
http://www.linuxhard.org
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.