library simple-translator
Very simple translator for static php web page
ajda2/simple-translator
Very simple translator for static php web page
- Thursday, January 26, 2017
- by ajda2
- Repository
- 1 Watchers
- 0 Stars
- 109 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 0 % Grown
simpleTranslator
Very simple static Translator for PHP, (*1)
Example of usage
use ajda2\Localization\ArrayTranslator;
require_once __DIR__ . '/../src/ITranslator.php';
require_once __DIR__ . '/../src/ArrayTranslator.php';
$strictMode = FALSE;
$enTable = require_once './translations/en.php'; // Get EN translations
$csTable = require_once './translations/cs.php'; // Get fallback for translations, not required
$translator = new ArrayTranslator($enTable, $csTable, $strictMode);
echo $translator->translate('form.validate.invalid_email') . PHP_EOL; // valid translation
echo $translator->translate('czech_only'); // return 'czech_only' because strictMode is disabled
$translator->setStrictMode(TRUE);
echo $translator->translate('czech_only'); // throw MissingTranslationException because of strict mode