34 throw new Exception(
"PO file ($pofile) doesn't exist.");
48 if (!empty($this->entries)) {
49 $js = json_encode($this->entries);
62 if (file_exists($this->pofile)) {
63 $pocontent = file_get_contents($this->pofile);
64 if ($this->encoding ===
'iso') {
65 $pocontent = utf8_encode($pocontent);
67 if ($pocontent !==
false) {
70 ( ^msgctxt \s+ (?P<msgctxt> ".*" \s* (^ ".*" \s*)* ) )?
72 ^msgid \s+ (?P<msgid> ".*" \s* (^ ".*" \s*)* )
74 ^msgstr \s+ (?P<msgstr> ".*" \s* (^ ".*" \s*)* )
76 /xmu', $pocontent, $matches, PREG_SET_ORDER);
77 foreach ($matches as $m) {
78 $this->
memoEntry($m[
'msgid'], $m[
'msgstr'], $m[
'msgctxt']);
81 throw new Exception(
"PO file ({$this->pofile}) is not readable.");
84 throw new Exception(
"PO file ({$this->pofile}) doesn't exist.");
93 protected function memoEntry($key, $text, $ctxt =
'')
101 $this->entries[
"_msgctxt_"][$ctxt][$key] = $text;
103 $this->entries[$key] = $text;
105 }
else if ($key ==
"") {
106 if (stristr($text,
"charset=ISO-8859") !==
false) {
107 $this->encoding =
'iso';
122 $lines = preg_split(
'/\s*\n+\s*/u', $lines);
124 $lines = array_filter($lines,
function ($v)
132 foreach ($lines as & $line) {
134 $line = preg_replace(
'/^\s*"(.*)"\s*$/u',
'\1', $line);
142 return implode(
"", $lines);
153 $str = preg_replace_callback(
'/\x5c([ntbrfva"\x5c]|[0-7]{1,3}|x[0-9a-fA-F][0-9a-fA-F])/u',
function ($m)
177 if (substr($seq, 0, 1) ==
'x') {
178 $seq = substr($seq, 1);
179 return hex2bin($seq);
182 return hex2bin(sprintf(
"%02s", dechex(octdec($seq))));
memoEntry($key, $text, $ctxt= '')
memoEntry($key, $text, $ctxt='')
unescapeGettextControlSeq($str)