PHP code example of jelix / simplelocalization

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

    

jelix / simplelocalization example snippets




return array(
    'welcome' => 'Hello world',
    'thank.you' => 'Thank you'
);



return array(
    'welcome' => 'Bonjour le monde',
    'thank.you' => 'Merci'
);



return array(
    'en' => array(
        'welcome' => 'Hello world',
        'thank.you' => 'Thank you'
    ),
    'fr' => array(
        'welcome' => 'Bonjour le monde',
        'thank.you' => 'Merci'
    )
);


// with multiple files
$locales = new \Jelix\SimpleLocalization\Container('translation.%LANG%.php');
// note that %LANG% in the path will be replace by a lang code

// with a single file
$locales = new \Jelix\SimpleLocalization\Container('translation.php');

// with an array of file name. You can mix path with `%LANG%` tag and path without it
$locales = new \Jelix\SimpleLocalization\Container(array('translation.%LANG%.php', 'other_translation.php'));


// with an array of strings
$locales = new \Jelix\SimpleLocalization\Container(array(
    'en' => array(
        'welcome' => 'Bonjour le monde',
        'thank.you' => 'Merci'
    ),
    'fr' => array(
        'welcome' => 'Bonjour le monde',
        'thank.you' => 'Merci'
    )
));


$str = $locales->get('welcome');