/** * Set locale * * @param string $locale */ public function setLocale($locale) { $this->locale = $locale; if ($this->checkTranslateObjectIsSet()) { $this->translation->setLocale($this->locale); } }
* * This example is part of gelembjuk/locale package by Roman Gelembjuk (@gelembjuk) */ // ==================== CONFIGURATION ================================== // path to your composer autoloader require 'vendor/autoload.php'; // folder where translations are stored $lang_folder_path = dirname(__FILE__) . '/lang/'; // get locale from url $locale = $_REQUEST['locale']; if ($locale == '') { // set english of not posted $locale = 'en'; } // create translation object $translation = new Gelembjuk\Locale\Translate(array('localespath' => $lang_folder_path, 'locale' => $locale)); // ============================================================= echo '<h1>Test 1. Welcome message</h1>'; $username = '******'; // return formatted text , insert user's info echo '<p>' . $translation->getText('hello', '', $username) . '</p>'; // return big translater text echo '<div>' . $translation->getText('about', 'frontpage') . '</div>'; // ============================================================= echo '<h1>Test 2. Class with translation functionality</h1>'; class MyClass { // include translation functions use Gelembjuk\Locale\GetTextTrait; public function doSomething() {