Learning patterns/Developing a fully internationalized and centralized gadget
A learning pattern forproject management
created on16 October, 2016
What problem does this solve? edit
Gadgets are usually a mess. Each wiki that adopts a gadget makes its own copy of the code and documentation, so any enhancements done by one wiki don't spread to others, and developers working on the same gadget can hardly collaborate.
What is the solution? edit
- Fully internationalize the gadget (example)
- Put the code on the MediaWiki namespace at Commons (example)
- Load the code from each wiki using the mw.loader.load method (example)
- Put the documentation on Commons and translate it to various languages (example)
- Request creation of a project tag for the gadget at Phabricator to track bugs and feature requests (example)
- Request a code repository in Gerrit to coordinate code review (example)
- Add the gadget to TranslateWiki to quickly localize all interface messages (example)
Things to consider edit
- To minimize requests to Commons, the loading script on each wiki should have some checks so that it only loads the gadget when it's likely to be used (for example only when editing a page, only on the mainspace, etc).
- Any wiki-specific configuration variables that the gadget may require can be set by the local wiki using the
mw.config.setmethod, and the gadget can get them using the
- Use the
wgContentLanguageglobal variables to figure out the appropriate interface language
- Get the latest localized messages directly from Gerrit by adding
?format=textto the file at Gitiles. The messages will come out base64-encoded but you can decode them like this.