Esempio n. 1
0
 public function execute($text)
 {
     $flocale = $this->getConfig()->getFolderLocale();
     $folder = glob("{$flocale}/*");
     $locale = $flocale . '/' . $this->getConfig()->getLocale();
     $locale_to = $this->getConfig()->getLocaleTo();
     $load_locale = array();
     foreach ($folder as $value) {
         if ($locale . '.yml' == $value) {
             $load_locale = Render::loadYAML($value);
         }
     }
     $load_locale_to = array();
     if ($locale_to) {
         foreach ($folder as $value) {
             if ($flocale . '/' . $locale_to . '.yml' == $value) {
                 $load_locale_to = Render::loadYAML($value);
             }
         }
     }
     if (count($load_locale) !== count($load_locale_to)) {
         return Render::text($text, $this->getLoadArgs());
     }
     $found = 0;
     foreach ($load_locale as $key => $val) {
         if (!is_array($val) && strcmp($text, $val) === 0) {
             $found++;
             return Render::text($load_locale_to[$key], $this->getLoadArgs());
         }
     }
     if ($found == 0) {
         return Render::text($text, $this->getLoadArgs());
     }
 }
Esempio n. 2
0
 public function execute($text)
 {
     $render = $this->loadLineSimpleYAML($text);
     $locale_to = $this->getConfig()->getLocaleTo();
     if (is_array($render)) {
         $text = $this->getStringRender($render, $locale_to);
         if (is_string($text)) {
             //return $return;
             return Render::text($text, $this->getLoadArgs());
         } else {
             return "No \"{$locale_to}\" text.";
         }
     }
     $render = Render::text($render, $this->getLoadArgs());
     return $render ? $render : "No \"{$locale_to}\" text.";
 }