Hello everybody,
I'm trying to figure out the best method for internationalization/localization of
MediaWiki Gadgets. There are several approaches implemented in the different available
gadgets, but none of them seem to use MediaWikis client side message system. I want to use
something like
mw.message('my-gadget-some-key').plain();
But this only works with message keys that are available on the client side, based on the
'messages' field of a server side module definition ($wgResourceModules). The
clientside
mw.loader.implement( moduleName, scripts, styles, messages );
has a parameter for a 'messages' config object. But it does not load the
translation texts for the keys automatically. Actually it expects a JavaScript object that
contains keys _and_ values [1]. I've tried whether the values get overridden when a
translation on the MediaWiki-namespace is available, but they don't seem to. Am I
missing something important? Can you recommend a method for I18N in a gadget?
Just for the record: I've been experimenting with keeping the messages in subpages
("MediaWiki:Gadget.-/de.js") in JSON format [2] and loading them on runtime via
AJAX [3]. I think this has some beauty because it's close to what MediaWiki does on
the server side. Unfortunately in this case I'll have to implement a language fallback
[4] by myself. Any thoughts or hints?
[1]
https://www.mediawiki.org/wiki/ResourceLoader/Features#Response
[2]
https://www.mediawiki.org/w/index.php?title=User%3AOsnard%2FGadget-Test%2Fd…
[3]
https://www.mediawiki.org/wiki/User:Osnard/Gadget-Test.js
[4]
https://www.mediawiki.org/wiki/Localisation#mediaviewer/File:MediaWiki_fall…
--
Robert Vogel
Softwareentwicklung
Hallo Welt! - Medienwerkstatt GmbH
Residenzstraße 2
93047 Regensburg
Tel. +49 (0) 941 - 66 0 80-198
Fax +49 (0) 941 - 66 0 80-189
www.hallowelt.biz
vogel(a)hallowelt.biz
Sitz: Regensburg
Amtsgericht: Regensburg
Handelsregister: HRB 10467
E.USt.Nr.: DE 253050833
Geschäftsführer: Anja Ebersbach, Markus Glaser, Dr. Richard Heigl, Radovan Kubani