PHP code example of pointdeb / translator

1. Go to this page and download the library: Download pointdeb/translator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pointdeb / translator example snippets





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 
/** 
 * 
 * $contents = [];
 * $contents['cover']['greeting'] = "Hello world";
 * $contents['cover']['getstarted'] = "Get Started";
 * return $contents;
 */

use Pointdeb\Translator\Translation;

$excel = '/path/to/your.xlsx';
$result = Translation::getFromExcel($excel);

/**
 * [
 *      'key' => [
 *          'en' => 'value',
 *          'fr' => 'valeur'            
 *      ]
 * ] 
 * 
*/

use Pointdeb\Translator\Translation;

$outputPath = '/your/path/';
$excel = '/path/to/your.xlsx';

$result = Translation::saveToFileFromExcel($excel, $outputPath);

// result /your/path/en/home.php 
/** 
 * 
 * $contents = [];
 * $contents['cover']['greeting'] = "Hello world";
 * $contents['cover']['getstarted'] = "Get Started";
 * return $contents;
 */