PHP code example of samsonos / php_i18n

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

    

samsonos / php_i18n example snippets


// SamsonPHP Configuration
 locales
setlocales('ru', 'fr');

// Run
s()->composer()->start();

<h1>This is ENGLISH view file</h1>

<h1>This is RUSSIAN view file</h1>

function test()
{
    m()->view('test')->title('Localization test');
}

<html>
    <body>
         m()->render()

function dictionary()
{
    return array(
        $locale => array(
            $key => $value,
            ...
        ),
        'ru' => array(
            'Translate me' => 'Переведи меня',
        )
    );
}

<h1> t('Translate me')

<html>
    <body>
         m('i18n')->render('list')

<html>
    <body>
        <ul class="i18n-list">
            <li class="i18n-locale-def i18n-active">
            <a href="/" class=""></a>
        </li><li class="i18n-locale-ru ">
            <a href="/ru"></a>
        </li><li class="i18n-locale-fr ">
            <a href="/fr"></a>
        </li></ul>
    </body>
</html>

<html>
    <body>
        <head>
             m('i18n')->render('meta')
samsonos\php\core\SamsonLocale::DEF
samsonos\php\core\SamsonLocale
index.php
index.php
samsonos\php\core\URL
samsonos\php\i18n
samsonos\php\core\URL
app/view/test.php
app/view/ru/test.php
app/view/controller/test.php
app/view/index.php
app/view/ru/test.php
app/view/test.php
app/view/i18n/dictionary.php
$key = 'Translate me'
$value = 'Переведи меня'
$key = 'Translate me'
$return = true|false
app/view/test.php
app/i18n/dictionary.php
app/view/index.php