PHP code example of piko / i18n

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

    

piko / i18n example snippets


return [
    'Translation test' => 'Test de traduction',
    'Hello {name}' => 'Bonjour {name}',
];

use Piko\Application;
use function Piko\I18n\__;

onents' => [
        'Piko\I18n' => [
            'translations' => [
                'app' => '@app/messages',
            ],
            'language' => 'fr'
        ],
    ],
];

$app = new Application($config);

$i18n = $app->getComponent('Piko\I18n');

echo $i18n->translate('app', 'Translation test') . '<br>'; // Test de traduction
echo $i18n->translate('app', 'Hello {name}', ['name' => 'John']) . '<br>' ; // Bonjour John

// Using the proxy function __() :
echo __('app', 'Translation test') . '<br>'; // Test de traduction
echo __('app', 'Hello {name}', ['name' => 'John']) . '<br>' ;  // Bonjour John

use Piko\I18n;
use function Piko\I18n\__;

ssages'], 'fr');

echo $i18n->translate('app', 'Translation test') . '<br>';
echo $i18n->translate('app', 'Hello {name}', ['name' => 'John']) . '<br>' ;

// Using the proxy function __() :

echo __('app', 'Translation test') . '<br>';
echo __('app', 'Hello {name}', ['name' => 'John']) . '<br>' ;


App root
  |__messages
    |__fr.php
  |__index.php