Jump to content

Help:Extension:Translate/Move translatable page

From mediawiki.org
Recommended prior reading: Help:Moving a page

When moving a source page that has been translated to other languages using the Translate extension, along with the source page the translation pages also have to be moved. Translation pages exist as subpages of the source page. For example, if we have a source page with the name FooBar, and the page has been translated to French, and Spanish, then the translation pages will exist at FooBar/fr and FooBar/es

The process to move a translated source page is the same as a normal page. The difference is in the way the subpages are moved.

In the image, we are moving a translatable source page. There are a few sections to note here,

  1. Translation page - These are the languages to which the source page has been translated to. This will be moved.
  2. Translation unit pages - These are the smallest individually tracked component of translatable pages: the page is divided into paragraph-sized translation units and each unit is a message. All of these will also be moved.
  3. Subpage marked for translation - These are other translatable source pages that exist as subpages under the source page that is being moved. These cannot be moved as part of the current move operation but has to be moved separately.
  4. Other subpage - These are normal subpages under the source translatable page that is being moved. The user can choose to move this by selecting the Move all subpages option on the screen.

Talk pages if present are also moved. Pages that have talk pages are denoted with a (Has talk page) suffix. Similar to subpages marked for translation, translatable talk pages have to be moved separately.

Once the user initiates the move process, the actual moving will be done via background jobs. The status of the "move job" can be tracked via the Page translation log.

Leaving a redirect: we provide a checkbox option that adds redirects for everything except translation unit pages and translation pages (translatable page, talk pages, regular subpages and their talk pages) once a page is moved.

From the user interface, by default, a maximum of 500 pages can be moved. This can be changed by modifying the config $wgTranslatePageMoveLimit. We recommend using the moveTranslatableBundle.php to move a large number of pages.

Moving a large number of pages

[edit]

To move a large number of pages, we recommend using the script moveTranslatableBundle.php as it can be slightly unreliable to do so via the UI, which uses the job queue to move the pages.

While moving the page, the script will perform the necessary validations, display what will be moved, and then take confirmation from the user before performing the move.

The script takes the following parameters:

current-page Required Current page name
new-page Required New page name
user Required User performing the move
reason Optional Reason for performing the move
skip-subpages Optional Skip moving subpages under the current page
skip-talkpages Optional Skip moving talkpages under the current page
skip-redirect Optional Skip leaving a redirect behind for translatable bundle, subpages and related talk pages

Example usage:

# Here "Main Page 60" is being renamed to "Main Page 70" by "Admin"
php extensions/Translate/scripts/moveTranslatableBundle.php "Main Page 60" "Main Page 70" Admin --reason "Just an example" --skip-redirect

Moving translated pages between wikis

[edit]

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:

Required? Description
Path Required Path to the exported XML file
--user Required Name of the user performing the import
--interwiki-prefix Required 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.

References

[edit]