PHP code example of geniv / nette-locale

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

    

geniv / nette-locale example snippets


use Locale\Locale;
$locale = $this->context->getByType(ILocale::class);

// or

/** @var Locale\ILocale @inject */
public $locale;

// methods implements `ILocale`:
getListName(): array;
getListId(): array;
getLocales(): array;

getCode(bool $upper = false): string
setCode(string $code)

// is correct locale set? with method: setCode()
// true if driver is DevNullDriver
isReady(): bool

getId(): int
getIdDefault(): string

getCodeDefault(bool $upper = false): string
isDefaultLocale(): bool
getPlural(): string
getIdByCode(string $code): int

public function onRequest(Application $application, Request $request) {}
json
"php": ">=7.0.0",
"nette/nette": ">=2.4.0",
"dibi/dibi": ">=3.0.0"
neon
parameters:
    default: "cs"
    locales:
       cs: "Čeština"
       en: "English"
       de: "Deutsch"
    plurals:
       cs: "$nplurals=3; $plural=($n==1) ? 1 : (($n>=2 && $n<=4) ? 2 : 0);"
       en: "$nplurals=2; $plural=($n != 1) ? 0 : 1;"
       de: "$nplurals=2; $plural=($n != 1) ? 0 : 1;"
       ru: "$nplurals=3; $plural=($n%10==1 && $n%100!=11 ? 0 : $n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? 1 : 2);"
    alias:
       sk: cs
       pl: en