Page MenuHomePhabricator

Missing i18n in JS: edit summaries for editing annotations
Open, MediumPublic

Description

JS code hardcodes the edit summaries for editing annotations (passed as parameters for #saveAnnotations) in English.

The hard part here is getting them to be in content language – ResourceLoader doesn't currently support that. We'd have to wait for T27349 or implement a subclass of ResourceLoaderFileModule that would handle it (example: MobileFrontend's MFResourceLoaderParsedMessageModule).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

For now I propose leaving it as-is, we can push this once we need to (I think a beta cluster deploy can live in this state for now)

or implement a subclass of ResourceLoaderFileModule that would handle it (example: MobileFrontend's MFResourceLoaderParsedMessageModule).

For the interim I'd recommend going with a data module. This is an established, stable and supported pattern. (Either as plain class like VisualEditorDataModule, or as FileModule subclass if you only ever need it within one module; to reduce module noise).

ResourceLoader recently gained a $context->msg() method, for use as $context->msg() or $context->msg()->inContentLanguage() inside getScript. Together with enableModuleContentVersion() this should make for a simple and low-maintenance module.

The only catch is that you need to enumerate the keys inside the PHP class rather than conveniently listing them inside extension.json (though I suppose you could make it a constructor option actually, it's a fresh class after all). You'll need a JS identifier to stash them in, either specific to the extension or a good ol' mw.config key (don't use mw.messages).

MarkTraceur moved this task from Untriaged to Next up on the Multimedia board.
MarkTraceur raised the priority of this task from Low to Medium.Sep 11 2017, 4:26 PM
MarkTraceur moved this task from Next up to Triaged on the Multimedia board.