Does anyone have any idea how we should proceed? It seems a bit like
overkill to run all the js through PHP for translation ...
--
Michael C. Harris, School of CS&IT, RMIT University
http://twofishcreative.com/michael/blog
Does anyone have any idea how we should proceed? It seems a bit like
overkill to run all the js through PHP for translation ...
> We're making good progress on making sure all text is run through the
> gettext functions, thanks mostly to Massimiliano. However, one issue
> that should be raised is how we should deal with text in javascript
> files. For example, see admin/js/admin.js lines 166-170, the
> "selected" bits. Obviously this can't get translated by the PHP
> functions.
>
> Does anyone have any idea how we should proceed? It seems a bit like
> overkill to run all the js through PHP for translation ...
Have a file with all JS strings, run that through gettext (in PHP) and
include it.
-Matt
I only found 9 obvious instances of text being set directly via
javascript so far that would need to be localized, so I'm feeling much
less concerned about this than I was when I first considered it.
The Stack class addresses concerns about script duplication. If an
enqueue_script()-like function is written, it should be added there,
perhaps like:
// register a script:
Stack::register('scriptname', '/path/to/script');
// add a registered script to a stack:
Stack::add('stackname', 'scriptname', Stack::REGISTERED);
// Output a stack through a javascript pre-cache:
Stack::out('stackname', array('Stack', 'js_precache'));
It has always been a thought of mine to provide some kind of server-side
caching and compression capabilities via the stack class for both
javascript and CSS output. The end result could be cached under a
hashed key of concatenated script names and times, and then served as a
single compressed javascript include file.
Regarding the javascript output itself, maybe we should consider using
something like this (MIT license):
http://code.google.com/p/gettext-js/source/browse
This seems as though it could load the gettext translation files
directly. All you'd need to do is add a line of javascript to tell the
browser to load (and hopefully cache) the translation file.
Owen
I only found 9 obvious instances of text being set directly via
javascript so far that would need to be localized, so I'm feeling much
less concerned about this than I was when I first considered it.
The Stack class addresses concerns about script duplication. If an
enqueue_script()-like function is written, it should be added there,
perhaps like:
// register a script:
Stack::register('scriptname', '/path/to/script');
// add a registered script to a stack:
Stack::add('stackname', 'scriptname', Stack::REGISTERED);
// Output a stack through a javascript pre-cache:
Stack::out('stackname', array('Stack', 'js_precache'));
It has always been a thought of mine to provide some kind of server-side
caching and compression capabilities via the stack class for both
javascript and CSS output. The end result could be cached under a
hashed key of concatenated script names and times, and then served as a
single compressed javascript include file.
Regarding the javascript output itself, maybe we should consider using
something like this (MIT license):
http://code.google.com/p/gettext-js/source/browse
This seems as though it could load the gettext translation files
directly. All you'd need to do is add a line of javascript to tell the
browser to load (and hopefully cache) the translation file.