31 throw new Exception(
"PO file ($pofile) doesn't exist.");
47 if (!empty($this->entries)) {
48 $js = json_encode($this->entries);
49 if ($this->encoding ===
"iso") {
50 $js = utf8_encode($js);
65 if (file_exists($this->pofile)) {
66 $pocontent = file_get_contents($this->pofile);
67 if ($pocontent !==
false) {
69 preg_match_all(
'/^(msgctxt (?P<msgctxt>".*?))?msgid (?P<msgid>".*?)msgstr (?P<msgstr>".*?")\n\n/ms',
70 $pocontent, $matches, PREG_SET_ORDER);
71 foreach ($matches as $m) {
72 $this->
memoEntry($m[
'msgid'], $m[
'msgstr'], $m[
'msgctxt']);
75 throw new Exception(
"PO file ({$this->pofile}) is not readable.");
78 throw new Exception(
"PO file ({$this->pofile}) doesn't exist.");
89 $tkey = explode(
"\n", $key);
90 $ttext = explode(
"\n", $text);
91 $tctxt = explode(
"\n", $ctxt);
92 $key = trim(implode(
"\n", array_map(
'Po2js::trimquote', $tkey)));
93 $text = trim(implode(
"\n", array_map(
'Po2js::trimquote', $ttext)));
94 $ctxt = trim(implode(
"\n", array_map(
'Po2js::trimquote', $tctxt)));
97 $this->entries[
"_msgctxt_"][$ctxt][$key] = $text;
99 $this->entries[$key] = $text;
101 }
else if ($key ==
"") {
102 if (stristr($text,
"charset=ISO-8859") !==
false) {
103 $this->encoding =
'iso';
110 return trim(
$s,
'"');
memoEntry($key, $text, $ctxt='')