Jump to content

User:APatro (WMF)/Move translatable bundles across wiki

From mediawiki.org

At times it maybe necessary to move translatable pages and message bundles across different wikis. This can be done via multiple approaches:

  • Through maintenance scripts

Maintenance script

[edit]

There are two scripts that can be used to export a translatable bundle from 1 wiki and then import it to another wiki.

Exporting

[edit]

To export the translatable bundle, run the export script on the wiki where the translatable bundle exists. This will create a file, that can be then used for import on the target wiki.

$ php maintenance/run.php ./extensions/Translate/scripts/exportTranslatableBundle.php --translatable-bundle "Page to translate" --filename /var/www/html/w/translate-2023-05-22.xml --include-talk-pages --include-subpages

Exporting 1 page(s) of type translatable bundle.
Exporting 5 page(s) of type translation.
Exporting 23 page(s) of type translation unit.
Exporting 1 page(s) of type talk pages.
Exporting 0 page(s) of type translatable talk.
Exporting 1 page(s) of type subpage.
Done! Exported bundle 'Translate-2023-05-22' to '/var/www/html/w/translate-2023-05-22.xml'.

The script expects the following parameters:

  • --translatable-bundle - Name of the translatable page to export
  • --filename - Name and path to save the export file to
  • --include-talk-pages - (Optional) Include talk pages
  • --include-subpages - (Optional) Include subpages.

Importing

[edit]

The file exported can then be imported into another wiki by running the import script:

php maintenance/run.php ./extensions/Translate/scripts/importTranslatableBundle.php translate-2023-05-22.xml --user Admin --interwiki-prefix "1" --comment "Hello world"

Completed import of file. Created page 'Translate-2023-05-22'
You can now mark the page 'Translate-2023-05-22' for translation.

The script expects the following parameters:

  • Path to the exported XML file
  • --user - Name of the user performing the import
  • --interwiki-prefix - Prefix to apply to unknown (and possibly also known) usernames
  • --assign-known-users - (Optional) Whether to apply the prefix to usernames that exist locally
  • --comment - (Optional) Comment added to the log for the import.

Limitation

[edit]
  • This only tags the translation, but does not mark the page for translation. That has to be done manually
  • For translatable pages, metadata such as priority languages are not exported / imported. Please add them when marking the page for translation.