1. Go to this page and download the library: Download surcoufx83/php-i18n 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/ */
surcoufx83 / php-i18n example snippets
composer
use I18N\i18n;
use I18N\L;
...
$i18n = new i18n();
$i18n->setCachePath('./tmp/cache');
$i18n->setFilePath('./langfiles/lang/lang_{LANGUAGE}.ini'); // language file path
$i18n->setFallbackLang('en');
$i18n->setPrefix('lang');
$i18n->setForcedLang('en'); // force english, even if another user language is available
$i18n->setSectionSeparator('_');
$i18n->setMergeFallback(false); // make keys available from the fallback language
...
echo L::greeting;
// If 'en' is applied: 'Hello World'
echo L::category_somethingother;
// If 'en' is applied: 'Something other...'
echo L::last_modified("today");
// Could be: 'Last modified: today'
echo L($string);
// Outputs a dynamically chosen static property
echo L($string, $args);
// Same as L::last_modified("today");
...
class My_i18n extends i18n {
public function getUserLangs() {
$userLangs = new array();
$userLangs[] = $_GET['language'];
$userLangs[] = $_SESSION['userlanguage'];
return $userLangs;
}
}
$i18n = new My_i18n();
// [...]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.