Learning patterns/Developing a fully internationalized and centralized gadget

A learning pattern forproject management
Developing a fully internationalized and centralized gadget
problemHow to fully centralize and internationalize a gadget
solutionHost the code and documentation at Commons, with local configs on each wiki
creatorSophivorus
endorse
created on16 October, 2016
status:DRAFT


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

  1. Fully internationalize the gadget (example)
  2. Put the code on the MediaWiki namespace at MediaWiki.org (example)
  3. Load the code from each wiki using the mw.loader.load method (example)
  4. Put the documentation on MediaWiki.org and translate it to various languages (example)
  5. Request creation of a project tag for the gadget at Phabricator to track bugs and feature requests (example)
  6. Request a code repository in Gerrit to coordinate code review (example)
  7. Add the gadget to TranslateWiki to quickly localize all interface messages (example)

Things to consider edit

  • To minimize requests to MediaWiki.org, 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.set method, and the gadget can get them using the mw.config.get method
  • Use the wgUserLanguage and wgContentLanguage global variables to figure out the appropriate interface language
  • Get the latest localized messages directly from Gerrit by adding ?format=text to the file at Gitiles. The messages will come out base64-encoded but you can decode them like this.

See also edit