Example #1
0
 public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager)
 {
     if ($aObject instanceof \org\jecat\framework\ui\xhtml\ObjectBase and !$aObject->count()) {
         Assert::type("org\\jecat\\framework\\ui\\xhtml\\Text", $aObject, 'aObject');
         $sText = $aObject->source();
         // locale translate
         do {
             if (!trim($sText)) {
                 break;
             }
             // 排除 script/style 等标签中的内容
             if ($aParent = $aObject->parent() and $aParent instanceof Node and in_array(strtolower($aParent->tagName()), array('script', 'style'))) {
                 break;
             }
             // 仅 title alt 等属性
             if ($aObject instanceof AttributeValue and !in_array(strtolower($aObject->name()), array('title', 'alt'))) {
                 break;
             }
             // 过滤 注释 和 doctype 声明
             if (preg_match('/^\\s*<\\!.*>\\s*$/', $sText)) {
                 break;
             }
             $sText = Locale::singleton()->trans($sText, null, 'ui');
         } while (0);
         $aDev->output($sText);
     } else {
         $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager);
     }
 }
Example #2
0
 public function message(Locale $aLocale = null)
 {
     if (!$aLocale and class_exists('Locale')) {
         $aLocale = Locale::singleton();
     }
     return $aLocale ? $aLocale->trans($this->sMessage, $this->arrArgvs) : @call_user_func_array('sprintf', array_merge(array($this->sMessage), $this->arrArgvs));
 }
Example #3
0
 public function message(Locale $aLocale = null)
 {
     if (!$aLocale) {
         $aLocale = Locale::singleton();
     }
     return $aLocale->trans($this->sMessage, $this->arrMessageArgs);
 }
Example #4
0
 /**
  * @return org\jecat\framework\fs\File
  */
 public function findCompiled($sSourceFile, $sNamespace, $bAutoCreate = false)
 {
     $sPath = $this->compiledFolderPath() . '/' . $this->compileStrategySignture() . '/' . Locale::singleton()->localeName() . '/' . $sNamespace . '/' . $sSourceFile . '.php';
     $aFile = new File($sPath);
     if ($bAutoCreate and !$aFile->exists()) {
         $aFile->create();
     }
     return $aFile;
 }
Example #5
0
 /**
  * @return org\jecat\framework\locale\Locale
  */
 public function locale()
 {
     return Locale::singleton();
 }