pointdeb / translator
Dynamic translation file generation for laravel framework based on key and values.
v0.1.0
2019-01-05 21:33 UTC
Requires
- php: ^7.1
- phpoffice/phpspreadsheet: ^1.6
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2025-02-07 06:07:31 UTC
README
Translator is a dynamic translation file generator for laravel framework based on key and values;
Installation
composer require pointdeb/translator
Usages
SaveToFile
<?php use Pointdeb\Translator\Translation; $datas = [ "home.cover.greeting" => [ "en" => "Hello world", "fr" => "Salut les gens", "mg" => "Salama tompoko" ], ]; $outputPath = '/your/path/'; foreach($datas as $key => $data) { $result = Translation::saveToFile($key, $data, $outputPath); } // result /your/path/en/home.php /** * <?php * $contents = []; * $contents['cover']['greeting'] = "Hello world"; * $contents['cover']['getstarted'] = "Get Started"; * return $contents; */
GetFromExcel
use Pointdeb\Translator\Translation; $excel = '/path/to/your.xlsx'; $result = Translation::getFromExcel($excel); /** * [ * 'key' => [ * 'en' => 'value', * 'fr' => 'valeur' * ] * ] * */
SaveToFileFromExcel (merge of GetFromExcel and SaveToFile)
use Pointdeb\Translator\Translation; $outputPath = '/your/path/'; $excel = '/path/to/your.xlsx'; $result = Translation::saveToFileFromExcel($excel, $outputPath); // result /your/path/en/home.php /** * <?php * $contents = []; * $contents['cover']['greeting'] = "Hello world"; * $contents['cover']['getstarted'] = "Get Started"; * return $contents; */
Tests
phpunit
Made with love 😄 and comming soon with awesome stuff, @Pointdeb