Hi Bartosz,
thank you very much. This is exactly the information I needed.
-- Robert
-----Ursprüngliche Nachricht----- Von: wikitech-l-bounces@lists.wikimedia.org [mailto:wikitech-l-bounces@lists.wikimedia.org] Im Auftrag von Bartosz Dziewonski Gesendet: Mittwoch, 23. Juli 2014 17:19 An: Wikimedia developers Betreff: Re: [Wikitech-l] Gadget I18N: Recommendation?
You can use mw.messages.set( { key: 'value', … } ) to set the message keys that are used by mw.message() and mw.msg(). No need for mw.loader.implement() (in fact, you should probably never call that function at all).
This has no i18n support by itself, so you have to handle that part yourself (either loading them from somewhere else or just keeping the entire list in source code). A very simple practical example (with no language fallback chain support, it just falls back to English):
var translations = { en: { 'my-gadget-some-key': "My message" }, pl: { 'my-gadget-some-key': "Moja wiadomość" } };
var userLanguage = mw.config.get( 'wgUserLanguage' ); mw.messages.set( translations[userLanguage] || translations.en );
_______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l