PHP code example of nabeghe / light-localization

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

    

nabeghe / light-localization example snippets


use Nabeghe\LightLocalization\Localizer;

/*
 * Example of Translations Directory:
 | /langs/
 |      /en/
 |          main.php
 |          messages.php
 |      /fa/
 |          main.php
 |          messages.php
 */

$defaultLocalizer = new Localizer(__DIR__.'/langs', 'en');
$localizer = new Localizer(__DIR__.'/langs', 'fa', $defaultLocalizer);

// value of `title` key, from `main.php` translation file (default value for second argument).
echo $localizer->get('title');

// value of `hello` key, from `messages.php` translation file.
echo $localizer->get('hello', 'messages');