PHP code example of danidoble / translation

1. Go to this page and download the library: Download danidoble/translation 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/ */

    

danidoble / translation example snippets



// __DIR__ . '/vendor/autoload.php'

// Instantiate Translation class
$translator = new \Danidoble\Translation\Translation();

// pass config file by parameter, here you need pass all route file
$translator->apply(__DIR__ . DIRECTORY_SEPARATOR .'es.json');


// __DIR__ . '/vendor/autoload.php'

// Instantiate Translation class
$translator = new \Danidoble\Translation\Translation();

// pass config file by parameter, here you need pass all route file
$lang = isset(__GET['lang']) && !empty(__GET['lang']) ? __GET['lang'].'.json' : 'br.json';

$file_lang = __DIR__ . DIRECTORY_SEPARATOR .$lang;

if(file_exist($file_lang){
    $translator->apply($file_lang);
}else{
    echo 'Language file not found :(';
}

echo __('hello');

echo \Danidoble\Translation\Translation::__('hello');

use \Danidoble\Translation\Translation as tr;

echo tr::__('hello');


// __DIR__ . '/vendor/autoload.php'

// Instantiate Translation class
$translator = new \Danidoble\Translation\Translation();

//return true if the copy has been success, otherwise return false
var_dump($translator->cpEsExampleFile(__DIR__.'/../Src/'));