Example #1
0
    use Gelembjuk\Locale\GetTextTrait;
    public function doSomething()
    {
        echo $this->getText('welcome') . '<br>';
    }
    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
<?php

interface MyInterface1
{
    public function doSomething();
    public function specialFunction1();
}
interface MyInterface2
{
    public function doSomething();
    // Prior to PHP 5.3.9 => FATAL ERROR
    public function specialFunction2();
}
class MyClass implements MyInterface1, MyInterface2
{
    function doSomething()
    {
        echo '...';
    }
    function specialFunction1()
    {
        echo '...';
    }
    function specialFunction2()
    {
        echo '...';
    }
}
$a = new MyClass();
$a->doSomething();