Ejemplo n.º 1
0
 /**
  * getOrphans
  *
  * @param boolean $flatten
  * @param int     $stripPrefix
  *
  * @return array
  */
 public static function getOrphans($flatten = true, $stripPrefix = 1)
 {
     $orphans = Translator::getInstance()->getOrphans();
     foreach ($orphans as $key => $value) {
         $value = explode('.', $key);
         $value = array_map('ucfirst', $value);
         foreach (range(1, $stripPrefix) as $i) {
             array_shift($value);
         }
         $value = implode(' ', $value);
         $orphans[$key] = $value;
     }
     if (!$flatten) {
         $reg = new Structure();
         foreach ($orphans as $key => $value) {
             $reg->set($key, $value);
         }
         $orphans = $reg->toArray();
     }
     return $orphans;
 }
Ejemplo n.º 2
0
 /**
  * langKey
  *
  * @param   string  $key
  *
  * @return  void
  */
 public static function translate($key)
 {
     static::translator();
     $asset = static::getAsset();
     $text = Translator::translate($key);
     /** @var Language $language */
     $language = Translator::getInstance();
     $handler = $language->getNormalizeHandler();
     $key = call_user_func($handler, $key);
     $asset->internalScript("Phoenix.Translator.addKey('{$key}', '{$text}')");
 }