Help:Extension:Translate/Import Translations via CSV
<translate> Translators</translate> (<translate> main help page</translate> )
- <translate> How to translate</translate>
- <translate> Best practices</translate>
- <translate> Statistics and reporting</translate>
- <translate> Quality assurance</translate>
- <translate> Message group states</translate>
- <translate> Offline translation</translate>
- <translate> Glossary</translate>
<translate> Translation administrators</translate>
- <translate> How to prepare a page for translation</translate>
- <translate> Page translation administration</translate>
- <translate> Unstructured element translation</translate>
- <translate> Group management</translate>
- <translate> Move translatable page</translate>
- <translate> Import translations via CSV</translate>
- <translate> Working with message bundles</translate>
<translate> Sysadmins and developers</translate>
- <translate> Installation</translate>
- <translate> Configuration</translate>
- <translate> Getting started with development</translate>
- <translate> Developer guide</translate>
- <translate> Extending Translate</translate>
- <translate> Validators</translate>
- <translate> Insertables</translate>
- <translate> Group configuration</translate>
- <translate> Group configuration example</translate>
- <translate> Translation memories</translate>
- <translate> Translation aids</translate>
- <translate> Enabling message bundles</translate>
- <translate> PHP hooks</translate>
This page describes the feature that allows translators to submit their translations via CSV to an system administrator, and then have it imported. <translate> task <tvar name=1>T309517</tvar></translate>
Steps
Exporting the CSV
First identify the page that you wish to submit translations via CSV. Example page: Development Guidelines.
Go to Special:ExportTranslations and export that page in CSV format in the French (fr) language.
The CSV file exported will be in the following format:
- Highlight 1 in image - Message definition in the source language
- Highlight 2 in image - Translations in the exported language. French in this case
Adding translations to the CSV
The file exported in the previous step can be modified to update existing translations or add more translations.
See the image below from the CSV file that has added a translation in Spanish (es), and some in Dutch (nl):
This file can then be given to the administrator to import the translations into the system.
Note
- Empty translations will be ignored. Translations will not actually be removed if a cell in the CSV is made empty.
- If no modification is made to a translation no new entries will be added to the translation change history.
Importing translations via CSV
The file received from the translator can be imported via a command line script made available in the translate extension importTranslationsFromCsv.php
:
The script expects the following parameters:
- Path to the CSV file
--user
- Name of the user performing the import--summary
- Edit summary to be used when updating the translations--really
- Actually perform the import. Without this a dry run will be carried out.
Example run
First, a dry run to see what will be imported:
$ php extensions/Translate/scripts/importTranslationsFromCsv.php ~/Projects/html/mediawiki/groups/page-Development\ Guidelines_to_import.csv --user Admin --summary "Importing translations from CSV"
* 3 translation(s) to import for Translations:Development Guidelines/Page display title/en
* 2 translation(s) to import for Translations:Development Guidelines/1/en
* 2 translation(s) to import for Translations:Development Guidelines/2/en
* 2 translation(s) to import for Translations:Development Guidelines/3/en
* 2 translation(s) to import for Translations:Development Guidelines/4/en
* 2 translation(s) to import for Translations:Development Guidelines/5/en
Use option --really to perform the import.
Now perform the actual import:
$ php ./extensions/Translate/scripts/importTranslationsFromCsv.php ~/Projects/html/mediawiki/groups/page-Development\ Guidelines_to_import.csv --user Admin --summary "Importing translations from CSV" --really
* 3 translation(s) to import for Translations:Development Guidelines/Page display title/en
* 2 translation(s) to import for Translations:Development Guidelines/1/en
* 2 translation(s) to import for Translations:Development Guidelines/2/en
* 2 translation(s) to import for Translations:Development Guidelines/3/en
* 2 translation(s) to import for Translations:Development Guidelines/4/en
* 2 translation(s) to import for Translations:Development Guidelines/5/en
Proceeding with import...
(1/6) Imported translations for Translations:Development Guidelines/Page display title/en with 0 failure(s) and 3 successful import(s) ...
(2/6) Imported translations for Translations:Development Guidelines/1/en with 0 failure(s) and 2 successful import(s) ...
(3/6) Imported translations for Translations:Development Guidelines/2/en with 0 failure(s) and 2 successful import(s) ...
(4/6) Imported translations for Translations:Development Guidelines/3/en with 0 failure(s) and 2 successful import(s) ...
(5/6) Imported translations for Translations:Development Guidelines/4/en with 0 failure(s) and 2 successful import(s) ...
(6/6) Imported translations for Translations:Development Guidelines/5/en with 0 failure(s) and 2 successful import(s) ...
Success: Import done