PHP code example of rancoud / i18n

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

    

rancoud / i18n example snippets


composer 

return [
    'Hello' => 'Bonjour'
];

$defaultDirectory = '/path/to/translations/';
$defaultLanguage = 'en';
I18N::setDefaults($directory, $defaultLanguage);

I18N::echo('Hello');
// it will produce in output 'Hello'

I18N::echo('another string');
// it will produce in output 'another string' because the key doesn't exist in the file

$string = I18N::get('Hello');
// it will return 'Hello'

// you can use different language file instead of the default one
$string = I18N::get('string in other lang', 'es');
// it will return the translation of 'string in other lang' present in the es.php file