PHP code example of mindplay / lang

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

    

mindplay / lang example snippets


use mindplay\lang;

echo lang::text("foo/bar", "Hello {who}", ["who" => "World"]); // => "Hello World"

lang::set("en");

$text = lang::translate("en", "foo/bar", "...");

$t = lang::domain("foo/bar");

echo $t("Hello {who}", ["who" => "World"]); // => "Hello World"
echo $t("Hi {who}", ["who" => "World"]); // => "Hi World"

lang::register("foo/bar", __DIR__ . "/lang");



return [
    'Hello, {world}' => 'Greetings, {world}',
    '{num} results'  => function ($num) { return $num != 1 ? "{$num} results" : "{$num} result"; }
];