[dokuwiki] [PATCH] Translatable Javascript strings
- From: "Gabriel Birke" <Gabriel.Birke@xxxxxxxxx>
- To: <dokuwiki@xxxxxxxxxxxxx>
- Date: Thu, 25 Oct 2007 16:18:22 +0200
Hello,
attached you will find a patch that enables translatable string for the
script.js file of plugins.
If you want to use translatable strings, create a file called lang.js in the
lang/en directory of your plugin. The lang.js file has the following
structure:
LANG.addTranslation('plugin_name', {
key1:'Text1',
key2:'Text2'
// etc ...
});
Here is a concrete example for a plugin named "exampleplugin":
LANG.addTranslation('exampleplugin', {
errmsg:'Wrong foo in bar!'
});
If you put a lang.js file in another language directory, for example
lang/de, the structure is the same and the keys of the default language will
be overwritten - if they exist in the foreign language file. A language file
of a foreign language can't introduce new keys.
Here is an example on how to use a translatable string in your script.js:
alert(LANG.plugins.exampleplugin.errmsg);
Keep in mind that your lang.js files must be UTF-8 encoded.
I would be glad if you could accept this modification.
Greetings,
Gabriel
Other related posts:
- » [dokuwiki] [PATCH] Translatable Javascript strings