1. Go to this page and download the library: Download moss/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/ */
moss / locale example snippets
$locale = new Locale('en_GB', 'UTC', 100);
echo $locale->locale(); // will print "en_GB"
$locale->locale('en_US'); // will change locale to en_US
echo $locale->language(); // will print "en"
echo $locale->territory(); // will print "GB"
echo $locale->currencySubUnit(); // will print 100
$locale->currencySubUnit(1000); // will change sub unit to 1000
echo $locale->timezone(); // will print "UTC"
$locale->timezone('Europe/Berlin'); will change default timezone (used by all date functions) to 'Europe/Berlin'
$translator = new Translator('en_GB', []);
$dictionary = new ArrayDictionary('en_GB', ['dude' => 'laddy']);
$translator = new Translator('en_GB', $dictionary);
echo $translator->trans('There be %placeholder%', ['placeholder' => 'Drachen'])
// prints dort Drachen
[
'apple.count' => '{0} There are no apples|{1} There is one apple|]1,19] There are %count% apples|[20,Inf] There are many apples'
]
echo $translator->transChoice('apple.count', $count)
// prints There are no apples when $count = 0
// prints There is one apple when $count = 1
// prints There are %count% apples when $count > 1 && $count >= 19
// prints There are many apples when $count >= 20
$multi = new MultiDictionary('en_GB');
$multi->addDictionary($dictionary, 0);