Learning patterns/Developing a fully internationalized and centralized gadget

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
A learning pattern forproject management
Developing a fully internationalized and centralized gadget
MechaDuck.png
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 Commons (example)
  3. Load the code from each wiki using the mw.loader.load method (example)
  4. Put the documentation on Commons and translate it to various languages (example)
  5. Create a project for the gadget at Phabricator to track bugs and feature requests (example)
  6. Request a repo at 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 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.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.

When to use[edit]

See also[edit]

Related patterns[edit]

External links[edit]

References[edit]