PHP code example of webtrendi / lexiconic
1. Go to this page and download the library: Download webtrendi/lexiconic 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/ */
webtrendi / lexiconic example snippets
/* detect current language */
if (isset($_GET['locale'])) {
$locale = $_GET['locale'];
} else {
$locale = 'en_CA';
} //if
/* setup environment */
putenv("LANG=" . $locale);
putenv("LANGUAGE=" . $locale);
setlocale(LC_ALL, $locale);
/* setup extractor */
$extractor = new \Lexiconic\Extractor\GettextExtractor('application', __DIR__ .'/locale/');
/* get term functions */
$_ = $extractor->getTermFunction();
/* Use string extractor function */
echo $_('Ok this is simple enough'), PHP_EOL;