ufirstgroup / laravel-lang-import-export by mruoss

A Laravel package providing artisan commands to import and export language files from and to CSV.
149,981
41
4
Package Data
Maintainer Username: mruoss
Maintainer Contact: michael.ruoss@ufirstgroup.com (Michael Ruoss)
Package Create Date: 2014-07-25
Package Last Update: 2024-04-24
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-08 03:14:39
Package Statistics
Total Downloads: 149,981
Monthly Downloads: 2,052
Daily Downloads: 153
Total Stars: 41
Total Watchers: 4
Total Forks: 40
Total Open Issues: 7

laravel-lang-import-export

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 array (
  'commands' =>
  array (
    'next' => 'Next',
    'prev' => 'Previous',
    'play' => 'Play',
  ),
  'tips' =>
  array (
    '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.

Installation

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' => array(
        /* ... */
        'UFirst\LangImportExport\LangImportExportServiceProvider'
    )

Usage

The package currently provides two commands, one for exporting the files and one for importing them back:

Export

php artisan lang-export:csv en_US navigation
php artisan lang-export:csv --output /some/file en_US navigation
php artisan lang-export:csv --delimiter=";" --enclosure='"' --output=/some/file en_US 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.

Import

php artisan lang-import:csv en_US navigation /some/file
php artisan lang-import:csv --delimiter=";" --enclosure='"' --escape='\\' en_US 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.