PHP code example of noroman / trans
1. Go to this page and download the library: Download noroman/trans 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/ */
noroman / trans example snippets
ale = 'ru';
// throw exceptions [optional] default: false
$strict = true;
$trans = new Trans([path-to-dir-dictionaries], $locale, $strict);
print_r($trans->get('Hello, World!'));
/**
* Exception: not found dictionary
* $trans->setLocale('de');
* $trans->get('Hello, World!')
*/
// silent mode
$locale = 'de';
$trans = new Trans([path-to-dir-dictionaries], $locale);
// output: Hello, World!
print_r($trans->get('Hello, World!'));