PHP code example of iwan07 / lang

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

    

iwan07 / lang example snippets


use Iwan07\Lang\Lang;

Lang::setLanguage('ru');

use Iwan07\Lang\Lang;

$lang = new Lang;

echo $lang->main_page;        // Вариант 1
echo $lang->msg('main_page'); // Вариант 2



return [
    'main_page' => "Главная страница",
    'about'     => "О проекте",
    'contact'   => "Наши контакты",
];



return [
    'main_page' => "Home page",
    'about'     => "About project",
    'contact'   => "Our contacts",
];



return [
    'link' => ["ссылка", "ссылки", "ссылок"],
];

// ...
echo $lang->num(1, 'link'); // "1 ссылка"
echo $lang->num(2, 'link'); // "2 ссылки"
echo $lang->num(5, 'link'); // "5 ссылок"

echo $lang->link; // "ссылка"



return [
    'link' => ["link", "links"],
];

// ...
echo $lang->num(1, 'link'); // "1 link"
echo $lang->num(2, 'link'); // "2 links"
echo $lang->num(5, 'link'); // "5 links"

echo $lang->link; // "link"