[dokuwiki] Re: Proposal for translatable Javascript strings in plugins

On Thu, 25 Oct 2007 13:40:53 +0200
"Gabriel Birke" <Gabriel.Birke@xxxxxxxxx> wrote:

> Hello,
> 
> I would like to have translatable strings in the javascript of a
> plugin I am currently developing (a color picker for the toolbar). I
> would propose the following convention:
> 
> The directory pluginname/lang/langname can contain the optional file
> "lang.js". Strings are stored like this:
> 
> LANG['plugins']['pluginname'] = {
>       stringname1:translation, 
>       stringname2:translation
> }
> 
> The language file of the currently selected language will be loaded
> in the function js_pluginscripts() in lib/exe/js.php. If the language
> file doesn't exist, the function will default to english.
> 
> If you have any counter proposals or other ideas, let me know,
> otherwise I will send a patch to the list shortly.

There is a mechanism for this in the core translation file. It's not
widely used yet (I think it's only two or three strings). It works like
this: $lang['js'] is an array and everything in it will be available in
javascript from the global LANG object.

I'd like to have the same mechanism in the plugins. So instead of
having a JS file to edit it should be in the lang.php file as well.
js.php should then make it available as you suggested in
LANG['plugins']['pluginname']

It makes sense to use the same mechanism in plugins as in core.

Andi


-- 
http://www.splitbrain.org

Other related posts: