Page MenuHomePhabricator

Enable translation import on wikis with Translate extension
Closed, ResolvedPublic

Description

The import of translations is currently disabled on wikis running the Translate extension; the import feature is disabled in CommonSettings.php with:

unset( $wgSpecialPages['ImportTranslations'] );

This special page allows bulk import of translations in gettext format.

Provided the extension is secure, I suggest enabling this feature for users in the 'translation administrator' group. The use case here is that some groups in WMF use commercial translation services, and it would be good to have a mechanism for bulk import of translations.

Adding Siebrand. Needs security sign-off, so adding Chris as well.


Version: unspecified
Severity: enhancement
See Also:
T59964: Importing an invalid gettext file causes "Fatal exception of type MWException"

Details

Reference
bz40341

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 12:59 AM
bzimport set Reference to bz40341.

One issue to consider: the export action cannot currently be restricted to only certain user groups – only the import action is restricted. That would mean that translators downloading the files couldn't upload those themselves.

So who's responsible for getting time allocated for security sign-off? Chris, can you please enlighten us?

(In reply to comment #1)

One issue to consider: the export action cannot currently be restricted to only
certain user groups – only the import action is restricted. That would mean
that translators downloading the files couldn't upload those themselves.

Let's get it enabled, and see what's needed from there. We tend to overanalyze and then design, develop and implement too complex functionality. Release early, release often, and respond agile is the way to go.

I took a quick initial look at it, and most things look ok, but there were a few pieces that I would like to look into further. Unfortunately, it hasn't been high on my priority list.

What is your schedule on this rolled out? Is there something that relies on this being in place?

(In reply to comment #4)

What is your schedule on this rolled out?

As soon as you approve.

Is there something that relies on
this being in place?

Comms want to be able to have paid translations, and to combine that with Wiki pages requires this functionality to get anywhere.

Please give it an appropriate priority for security review. It's the critical path.

*** Bug 41700 has been marked as a duplicate of this bug. ***

Sorry for the delay in reviewing this.

In general, I'm not a fan of our servers making http calls to arbitrary urls-- a hostile user could start messing with our backend servers directly, or run attacks against other servers from our cluster, etc.

Would it be possible to add a config of allowed methods, which gets checked, and we allow users to upload, but not url import?

(In reply to comment #7)

Sorry for the delay in reviewing this.

In general, I'm not a fan of our servers making http calls to arbitrary
urls--
a hostile user could start messing with our backend servers directly, or run
attacks against other servers from our cluster, etc.

Would it be possible to add a config of allowed methods, which gets checked,
and we allow users to upload, but not url import?

Effectively what we're currently doing for HTTP sideloading from flickr

(In reply to comment #7 by Chris Steipp)

I'm not a fan of our servers making http calls to arbitrary urls--
Would it be possible to add a config of allowed methods, which gets checked,
and we allow users to upload, but not url import?

Siebrand?

Related URL: https://gerrit.wikimedia.org/r/60983 (Gerrit Change I01057787abcf9cbcf9796cac7750134858ebff7b)

I submitted gerrit 60983. Once merged, this should satisfy the request from comment 4, and the import feature for Translate could be enabled on Wikimedia wikis.

Gerrit 60983 is being merged and this will go live on Wikimedia in 1.22wmf3 from today on. A patch set can now be prepared to re-enable Special:ImportTranslations, as it's disabled with "unset( $wgSpecialPages['ImportTranslations'] );" in http://noc.wikimedia.org/conf/highlight.php?file=CommonSettings.php.

Marking "easy" now.

Related URL: https://gerrit.wikimedia.org/r/63684 (Gerrit Change I4fd12988bb21f5132c718aeec05a2dc112640566)

  1. Nobody has the right to import translations
  2. Exporting to gettext is still disabled

(In reply to comment #14)

  1. Nobody has the right to import translations
  2. Exporting to gettext is still disabled

The bug title doesn't request export. And no one asked for any rights to import translations, just enable translation import ;)

(In reply to comment #15)

The bug title doesn't request export.

True, it's not the use case comment 0 asked; however, the usual workflow is export -> translate -> import, so having only import makes little sense in general and may well be a requirement also for the services comment 0 had in mind.

And no one asked for any rights to
import
translations, just enable translation import ;)

Comment 0 asked the right (translate-import) to be added to translation admin group.

Related URL: https://gerrit.wikimedia.org/r/64919 (Gerrit Change I9f6b620c69b559214aa87d8fc96a19436a5687ee)

(In reply to comment #5)

(In reply to comment #4)

What is your schedule on this rolled out?

As soon as you approve.

Is there something that relies on
this being in place?

Comms want to be able to have paid translations, and to combine that with
Wiki
pages requires this functionality to get anywhere.

To mention a current example, we (WMF Communications team) will receive a batch of such commercial translations on May 28 and plan to import them to Meta for community review right after that. I earlier did this by bot (https://meta.wikimedia.org/wiki/User:HaeBot ) racking up thousands of edits (one for each imported translation unit), but needless to say, a working gettext import functionality would greatly facilitate this task for me, and make it possible in the first place for other translation admins who do not want to install and operate a bot.

The gettext import option should also be useful for converting translated wiki pages on Meta from the old translation system to the new format using the Translate extension (https://bugzilla.wikimedia.org/show_bug.cgi?id=46645 ).

Please give it an appropriate priority for security review. It's the critical
path.

https://gerrit.wikimedia.org/r/64919 (Gerrit Change I9f6b620c69b559214aa87d8fc96a19436a5687ee) | change APPROVED and MERGED [by jenkins-bot]

(In reply to comment #19)

https://gerrit.wikimedia.org/r/64919 (Gerrit Change
I9f6b620c69b559214aa87d8fc96a19436a5687ee) | change APPROVED and MERGED [by
jenkins-bot]

Tilman, [[m:Special:ImportTranslations]] is available since then (May), have you ever tried it?

(In reply to comment #20)

(In reply to comment #19)

https://gerrit.wikimedia.org/r/64919 (Gerrit Change
I9f6b620c69b559214aa87d8fc96a19436a5687ee) | change APPROVED and MERGED [by
jenkins-bot]

Tilman, [[m:Special:ImportTranslations]] is available since then (May), have
you ever tried it?

Hi Nemo, yes, I had noticed a while ago that Special:ImportTranslations is now available. However, I backed off after noticing that a) this bug had not been closed yet and b) that the export function, while recommended in the documentation for offline translation and linked in the translation interface on Meta, gave a "not supported" error. (In the meantime, I have again resorted to importing translations by bot instead.)

I have now looked into it again and tried to import .po files on Meta and on testwiki. After figuring out the file format (which would be much easier if the export function were available), and manually adding a missing interface message (https://meta.wikimedia.org/wiki/MediaWiki:Translate-manage-import-done ), I reached the point where the software indicates that the import is complete ("All done"). However, no translations are actually imported - according to the recent translation changes page and the logs, nothing happened at all.

Before I spend even more time on this and file a separate bug for this problem, it would be great if someone from the language engineering team could do a quick verification that the import function is actually working at all on Meta-wiki, i.e. that is has imported at least one file successfully. At that point we could probably close this bug. If it's necessary to open a separate bug for the missing export function, then so be it.

I think $wgTranslateTasks may need to have this added:

'export-as-po' => 'ExportasPoMessagesTask'

Will look into it once I complete what I was working on when I read this reply...

Change 99070 had a related patch set uploaded by Siebrand:
Allow exporting files as gettext in Translate

https://gerrit.wikimedia.org/r/99070

Change 99070 merged by jenkins-bot:
Allow exporting files as gettext in Translate

https://gerrit.wikimedia.org/r/99070

Thanks to hashar/Antoine, the configuration change was made active. I've made a successful roundtrip as can be observed at https://meta.wikimedia.org/w/index.php?title=Special%3AContributions&contribs=user&target=Siebrand&namespace=1198&limit=5.

I've found an issue with a missing message, that I'll be adding soon. It may take a week or so before that hits Wikimedia wikis, so no need to report a bug when you see "<translate-manage-import-ok>" on Special:ImportTranslations. That patch set will show up here once I submit it.

Change 99083 had a related patch set uploaded by Siebrand:
Add missing string 'translate-manage-import-ok'

https://gerrit.wikimedia.org/r/99083

Change 99083 merged by jenkins-bot:
Add missing strings

https://gerrit.wikimedia.org/r/99083

For some reason gerrit 99083 wasn't auto-notified as having been merged.

This is great, thanks! With export working, I was able to adapt my file and get the import to work.

I tried to import translations from a .po file via the web interface Special:ImportTranslations, and it works only when modifying existing messages, not when creating messages.

By diving in the code MessageWebImporter::execute, I see there is a call to self::doAction for existing messages, but there is no such call for non-existant messages, so is it really missing? (I successfully imported new messages from the command line script, my question is really about the web interface.)

To be transparent, this feature is requested by a client, if needed I can write the missing part for the web interface.