codemix / yii2-excel-message
Translate new messages via excel files
Installs: 4 131
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 6
Forks: 4
Open Issues: 0
Type:yii2-extension
Requires
- phpoffice/phpspreadsheet: ^1.2
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-10-24 04:41:36 UTC
README
Translate messages via Excel files.
Features
With this extension you can export messages from PHP message files to Excel, send them to your translators and read them back into your message files.
Note: To read and write to and from Excel file, we use the excellent PhpSpreadsheet package.
Installation
Install the package with composer.
composer require codemix/yii2-excel-message
Then update your console configuration:
<?php return [ 'controllerMap' => [ 'excel-message' => [ 'class' => 'codemix\excelmessage\ExcelMessageController' ] ] // ... ];
Creating Excel files with new translations
To create Excel files with new translations, you need to supply the Yii2 message configuration and the output directory where the files should be written to:
./yii excel-message messages/config.php /output/dir
This will create one file per language (filename == language) with one sheet per
category. The source messages are listed in column A
. Translators should add their
translations to column B
.
The files will be in Excel2007
format with xlsx
extension.
If you want a file with all translations instead, pass all
as 3rd argument. You can
also export only certain languages or categories:
./yii excel-message --languages=de,fr --categories=nav,app messages/config.php /output/dir
Update PHP message files from Excel files
After you receive the Excel files back from your translators you can update your PHP message files. Again you need to supply the Yii2 message configuration and the directory path where your Excel files are:
./yii excel-message/import messages/config.php /input/dir
This will add the new translations to your PHP message files. Yes it's really that simple.
You can also pass a third parameter with the file extension, the default is xlsx
as used by Excel 2007+ files. PhpSpreadsheet should also autodetect other Excel formats
Note: The files must be provided in the same format as they where created by the export:
- One file per language with language code as filename
- One sheet per category
- Source messages in column
A
, translations in columnB
- First line is skipped.
Options
You can use the following options.