Esempio n. 1
0
 /**
  * Generate Javascript from the internal strings.
  *
  * @return string
  */
 public function getScript()
 {
     $parts = [];
     foreach ($this->strings as $k => $v) {
         $parts[] = $k . ': "' . addslashes($this->transEsc->__invoke($v)) . '"';
     }
     return $this->varName . ' = {' . implode(',', $parts) . '};';
 }
Esempio n. 2
0
 /**
  * Generate JSON from the internal strings.
  *
  * @return string
  */
 public function getJSON()
 {
     $parts = [];
     foreach ($this->strings as $k => $v) {
         $translation = is_array($v) ? call_user_func_array([$this->transEsc, '__invoke'], $v) : $this->transEsc->__invoke($v);
         $parts[] = $k . ': "' . addslashes($translation) . '"';
     }
     return '{' . implode(',', $parts) . '}';
 }