Example #1
0
    }
    public function andAgainWelcome($name)
    {
        // use short call for getText
        echo $this->_('hello', '', $name) . '<br>';
        echo $this->_('contact', 'frontpage') . '<br>';
    }
}
$obj = new MyClass();
// this meathod comes from a trait
$obj->setTranslation($translation);
$obj->doSomething();
$obj->andAgainWelcome($username);
echo '<br><br>';
// change to english
$obj->setLocale('en');
// and repeat
$obj->andAgainWelcome($username);
// =============================================================
echo '<h1>Test 3. Show language change select box</h1>';
// output form to change locale
$languages = new Gelembjuk\Locale\Languages(array('localespath' => $lang_folder_path));
echo '<hr><form name=\'langform\' method=\'GET\' action="index.php">';
echo $languages->getHTMLSelect(' name="locale" onchange="document.langform.submit()" ', $locale);
echo '</form>';
// =============================================================
// output EU languages
$eulanguages = $languages->getLanguagesFiltered('EU');
echo '<hr><h2>EU Languages</h2><ul>';
foreach ($eulanguages as $lang) {
    echo '<li>' . $lang['name'] . '<br>';