帮助:扩展:翻译/移动可翻译页面
在使用翻译扩展将已翻译为其他语言的源页与源页一起移动时,也必须移动翻译页。 翻译页面作为源页面的子页面存在。 例如,如果我们有一个名称为FooBar的源页面,并且该页面已被翻译成法语和西班牙语,则翻译页面将分别为FooBar/fr和FooBar/es
移动翻译后的源页的过程与普通页相同。 不同之处在于子页面的移动方式。

在图像中,我们正在移动一个可翻译的源页。 这里有几个部分需要注意,
- 翻译页 - 这些是源页面被翻译成的语言。 这将被移走。
- 翻译单位页面 - 这些是可翻译页面中最小的单独跟踪组件:页面被划分为段落大小的翻译单元,每个单元都是一条消息。 所有这些都将被移走。
- 标记为翻译的子页 - 这些是其他可翻译的源页,它们作为子页存在于要移动的源页下。 这些不能作为当前移动操作的一部分进行移动,而必须单独移动。
- 其他子页面 - 这些是正在移动的源可翻译页面下的普通子页面。 用户可以通过选择屏幕上的“移动所有子页面”选项来选择移动。
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.
一旦用户启动移动过程,实际的移动将通过后台作业完成。 可以通过页面翻译日志跟踪“移动作业”的状态。
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.
$wgTranslatePageMoveLimit来更改。
移动大量页面
要移动大量页面,我们建议使用脚本moveTranslatableBundle.php,因为通过使用JobQueue来移动页面的UI执行此操作可能会稍显不可靠。
在移动页面时,脚本将执行必要的验证,显示要移动的内容,然后在执行移动之前获得用户的确认。
该脚本采用以下参数:
| Parameter | Status | Description |
|---|---|---|
current-page |
Required | 当前页面名称 |
new-page |
Required | 新页面名称 |
user |
Required | 执行移动的用户 |
reason |
Optional | (可选)执行移动的原因 |
skip-subpages |
Optional | (可选)跳过当前页面下的移动子页面 |
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 |
用法示例:
# 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
At times it may be necessary to move translatable pages and message bundles across different wikis. This can be done via maintenance scripts.
There are two scripts that can be used to export a translatable bundle from 1 wiki and then import it to another wiki.
Exporting
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:
| Parameter | Status | Description |
|---|---|---|
--translatable-bundle |
Required | Name of the translatable page to export |
--filename |
Required | Name and path to save the export file to |
--include-talk-pages |
Optional | Include talk pages |
--include-subpages |
Optional | Include subpages. |
Importing
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:
| Parameter | Status | 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. |
Limitations
- 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.