PHP code example of lombokclarion / i18n

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

    

lombokclarion / i18n example snippets


LombokClarion\I18n

use LombokClarion\I18n\Translator;

$translator = new Translator('resources/lang');
$translator->setLocale('id');

echo $translator->get('welcome'); // from resources/lang/id.php
echo $translator->get('greeting', ['name' => 'Budi']); // "Halo, Budi"

$router->group('/app', [DetectLocale::class], function (Router $r) {
    // All routes here auto-detect locale from Accept-Language
});