Multilingual website, texts in external JavaScript problem

Multilingual website, texts in external JavaScript problem

am 09.11.2009 07:04:07 von leledumbo

I need to create a multilingual website and my framework already gives me
that facility. However, I also use JavaScript quite extensively and since
XHTML 1.0 Strict doesn't allow inline script, I must use external .js file.
The problem is in these scripts, there are strings that needs to be
translated as well. How can I make PHP parse these scripts as well? Or are
there alternative approaches?

--
View this message in context: http://old.nabble.com/Multilingual-website%2C-texts-in-exter nal-JavaScript-problem-tp26261666p26261666.html
Sent from the PHP - General mailing list archive at Nabble.com.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Multilingual website, texts in external JavaScriptproblem

am 09.11.2009 11:52:40 von Ashley Sheridan

--=-QXn0Zq1wEE4QMVnHosr8
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sun, 2009-11-08 at 22:04 -0800, leledumbo wrote:

> I need to create a multilingual website and my framework already gives me
> that facility. However, I also use JavaScript quite extensively and since
> XHTML 1.0 Strict doesn't allow inline script, I must use external .js file.
> The problem is in these scripts, there are strings that needs to be
> translated as well. How can I make PHP parse these scripts as well? Or are
> there alternative approaches?
>
> --
> View this message in context: http://old.nabble.com/Multilingual-website%2C-texts-in-exter nal-JavaScript-problem-tp26261666p26261666.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>


You could either use several different Javascript files to hold the
language translations and just those as variables, and then in the main
Javascript use the variables rather than the actual words. Or you could
store all the translations into a Javascript array and refer to the
specific array element you need to output

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-QXn0Zq1wEE4QMVnHosr8--

Re: Multilingual website, texts in external JavaScript problem

am 09.11.2009 12:54:51 von Peter Ford

leledumbo wrote:
> I need to create a multilingual website and my framework already gives me
> that facility. However, I also use JavaScript quite extensively and since
> XHTML 1.0 Strict doesn't allow inline script, I must use external .js file.
> The problem is in these scripts, there are strings that needs to be
> translated as well. How can I make PHP parse these scripts as well? Or are
> there alternative approaches?
>

I don't see why you can't use inline script in XHTML 1.0 Strict: just put the
script in CDATA sections, like



That seems to validate fine in XHTML 1.0 Strict for me...


--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Multilingual website, texts in external JavaScript problem

am 09.11.2009 13:50:42 von Phpster

On Nov 9, 2009, at 1:04 AM, leledumbo
wrote:

>
> I need to create a multilingual website and my framework already
> gives me
> that facility. However, I also use JavaScript quite extensively and
> since
> XHTML 1.0 Strict doesn't allow inline script, I must use
> external .js file.
> The problem is in these scripts, there are strings that needs to be
> translated as well. How can I make PHP parse these scripts as well?
> Or are
> there alternative approaches?
>
> --
> View this message in context: http://old.nabble.com/Multilingual-website%2C-texts-in-exter nal-JavaScript-problem-tp26261666p26261666.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

I use a standard error code ( error.2510 ) treating it as the js array
key, and then call the correct language file with translated value

Bastien

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Multilingual website, texts in external JavaScriptproblem

am 10.11.2009 07:03:32 von leledumbo

> I don't see why you can't use inline script in XHTML 1.0 Strict

Because I don't know about CDATA, thanks.
--
View this message in context: http://old.nabble.com/Multilingual-website%2C-texts-in-exter nal-JavaScript-problem-tp26261666p26278740.html
Sent from the PHP - General mailing list archive at Nabble.com.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Multilingual website, texts in external JavaScriptproblem

am 10.11.2009 11:43:34 von Peter Ford

leledumbo wrote:
>> I don't see why you can't use inline script in XHTML 1.0 Strict
>
> Because I don't know about CDATA, thanks.

Glad to be of service!
As another regular contributor to this list often points out, there's always
something new to learn :)

--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php