Exemplo n.º 1
0
 /** Fill the places Holder withs vars */
 private static function fill($text, $vars)
 {
     if ($vars != null and !empty($vars)) {
         $hFormater = msgfmt_create('fr_FR', $text);
         $text = msgfmt_format($hFormater, $vars);
     }
     return $text;
 }
Exemplo n.º 2
0
 private function format($key, $params)
 {
     if ($this->translations[$key] == '') {
         return '';
     }
     $fmt = msgfmt_create($this->locale, $this->translations[$key]);
     if (!$fmt) {
         throw new \Exception('msgfmt_create() failed');
     }
     $result = msgfmt_format($fmt, $params);
     if (false === $result) {
         throw new \Exception('msgfmt_format() failed: ' . msgfmt_get_error_message($fmt) . ' (' . msgfmt_get_error_code($fmt) . ')');
     }
     return $result;
 }
 protected function parse($str, $args, $locale)
 {
     if (empty($str)) {
         return "";
     }
     // This is one of those weird ICU formatting standard things.
     $msg = msgfmt_create($locale, $str);
     $output = msgfmt_format($msg, $args);
     return $output;
 }