Beispiel #1
0
 public function init()
 {
     Registry::set('config', new Config());
     // Initializing the language
     $translation = Translate::getInstance();
     // If requested with ?lang=<lang> we load the language.
     $lang = $translation->getLanguageToLoad();
     $translation->loadLanguage($lang);
 }
Beispiel #2
0
/**
 * Get phrase translation
 * @param string $phrase to Translate
 * @lang  string $lang Destination language
 */
function _t($phrase, $lang = null)
{
    return Translate::getInstance($lang ? $lang : Config::get("language"))->getPhrase($phrase);
}
Beispiel #3
0
function __($message)
{
    $message = Translate::getInstance()->get($message);
    # if ( !( 'UTF-8' == mb_detect_encoding($message) ) )
    #     $message = utf8_encode($message);
    $params = array_slice(func_get_args(), 1);
    foreach ($params as $i => $param) {
        if (is_object($param) && method_exists($param, '__toString')) {
            $param = $param->__toString();
        }
        $message = str_replace("\${$i}", $param, $message);
    }
    return $message;
}
Beispiel #4
0
 function replace($link)
 {
     if (!preg_match('~^http://~', $link[2])) {
         $parts = explode('?', $link[2]);
         if (empty($parts[1])) {
             return $link[0];
         }
         $lt = Translate::getInstance();
         $link[2] = str_replace('&amp;', '&', $link[2]);
         $link[2] = $lt->params2cool(Functions::convertQueryStringToArray($parts[1]), $parts[0]);
         unset($link[0]);
         return implode('', $link);
     } else {
         return $link[0];
     }
 }
 public static function preFilterLang($templateContent)
 {
     self::$translate = Translate::getInstance(Config::get("language"));
     $templateContent = str_replace('|objurl', '|@objurl', $templateContent);
     $pattern = '#\\{\'([^\']+)\'\\|lang\\}#';
     $templateContent = preg_replace_callback($pattern, array("AppTemplateLiteView", "preFilterLangMatchCallback"), $templateContent);
     return $templateContent;
 }
Beispiel #6
0
 /**
  * @todo Implement testGetInstance().
  */
 public function testGetInstance()
 {
     $instance = Translate::getInstance();
     // Check if getInstance() returns correct object.
     $this->assertTrue(is_a($instance, 'MongoUI\\Core\\Translate'));
 }