PHP code example of delfimov / translate

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

    

delfimov / translate example snippets


<pre>

use DElfimov\Translate\Translate;
use DElfimov\Translate\Loader\PhpFilesLoader;
use Monolog\Logger; // PSR-3 logger, not WARNING));

$t = new Translate(
    new PhpFilesLoader(__DIR__ . "/messages"),
    [
        "default" => "en",
        "available" => ["en", "ru"],
    ],
    $log // optional
);

$num = rand(0, 100);

$t->setLanguage("en"); // this is not keys", $num, ['tree', $num]) . "\n\n";



return [
    'some string' => 'Some string',
    '%d liters' => ['%d liter', '%d liters'],
    '%d liters alt' => '%d liter|%d liters',
    'The %s contains %d monkeys' => ['The %s contains %d monkey', 'The %s contains %d monkeys'],
    'The %s contains %d monkeys alt' => 'The %s contains %d monkey|The %s contains %d monkeys',
];


return [
    'some string' => 'Просто строка',
    '%d liters' => '%d литр|%d литра|%d литров',
    'The %s contains %d monkeys' => ['На %s сидит %d обезьяна', 'На %s сидят %d обезьяны', 'На %s сидят %d обезьян'],
    'The %s contains %d monkeys alt' => 'На %s сидит %d обезьяна|На %s сидят %d обезьяны|На %s сидят %d обезьян',
    'tree' => 'дереве'
];