Page MenuHomePhabricator

Support translation of JSON blobs in Translate
Closed, DuplicatePublic

Description

Translate currently does not support the gadget use case well: some JS script has dozens of interface strings that need to be localized, the script needs to be able to load them efficiently and the translations need to be stored centrally (so that e.g. the German Wikipedia, German Wiktionary and German Wikibooks don't have to independently re-translate it). Translate on translatewiki.net would work but 1) way too cumbersome to set up, 2) gadgets currently don't have good support for using custom MediaWiki messages.

The obvious solution is to define the messages as a JSON blob (with message names as keys and English text as values) and allow them to be translated. (It's already being done by some gadgets currently, by creating a wiki page that happens to be a JSON blob, and littering it with <translate> tags, but that's obviously a poor replacement.) It would be nice if Translate supported this use case properly.

This is very similar to T155100: Support translation of localizable strings in data .tab pages through the Translate extension (maybe even obsoleted by it, although JSON seems a lot more straightforward to use than tabular data files).

Event Timeline

This could work similarly to page translation:

  • Messages would be duplicated somewhere, most likely in Translations or MediaWiki namespace.
  • The json translation pages would be updated on every edit

It would be different:

  • No <translate> tags

And some things to be decided:

  • Registration for translation: Automatic (how? category? page name?) or manual?
  • Marking translations outdated: automatically on every edit? automatic but with a delay to allow reverts? manually?

Possible obvious note: until central/crosswiki gadgets (gadgets 2.0 or 3.0) become a thing, we need to consider the need to sync translations from a wiki to another. Currently you "only" have to copy a blob of JSON from one wiki to another N times.

Possible obvious note: until central/crosswiki gadgets (gadgets 2.0 or 3.0) become a thing, we need to consider the need to sync translations from a wiki to another. Currently you "only" have to copy a blob of JSON from one wiki to another N times.

The reasonable approach and longtime practice for that is to store translations (along with the code itself) on a central wiki and load from there.

We are currently working on this. It's called Message Bundles and it's in the early stages.