This package provides artisan commands to import and export language files from and to CSV. This can be used to send translations to agencies that normally work with Excel-like files.
It turns some navigation.php file...
<?php
return [
'commands' => [
'next' => 'Next',
'prev' => 'Previous',
'play' => 'Play',
],
'tips' => [
'next' => 'Navigate to the next item',
'prev' => 'Navigate to the previous item',
'play' => 'Autoplay the slide show',
],
];
...to the following CSV...
navigation.commands.next,Next
navigation.commands.prev,Previous
navigation.commands.play,Play
navigation.tips.next,"Navigate to the next item"
navigation.tips.prev,"Navigate to the previous item"
navigation.tips.play,"Autoplay the slide show"
...and vice versa.
Add the following line to the require
section of your Laravel webapp's composer.json
file:
"require": {
"ufirst/lang-import-export": "dev-master"
}
Run composer update
to install the package.
Finally add the following line to the providers
array of your app/config/app.php
file:
'providers' => [
/* ... */
UFirst\LangImportExport\LangImportExportServiceProvider::class
]
The package currently provides two commands, one for exporting the files and one for importing them back:
php artisan lang-export:csv en navigation
php artisan lang-export:csv --mirror=sv,es,ch en navigation
php artisan lang-export:csv --output /some/file en navigation
php artisan lang-export:csv --delimiter=";" --enclosure='"' --output=/some/file en navigation
You have to pass the locale and the group as arguments. The group is the name of the langauge file without its extension. You may define options for your desired CSV format.
You can pass comma separated locales with the --mirror argument to get matching phrases for that locale in the same output.
php artisan lang-import:csv en navigation /some/file
php artisan lang-import:csv en all /some/file
php artisan lang-import:csv --delimiter=";" --enclosure='"' --escape='\\' en navigation /some/file
You have to pass the locale, the group and the path to the CSV file as arguments. The group is the name of the langauge file without its extension. You may define options to match the CSV format of your input file.
If you pass all as group it will loop the given file and find all available groups.