Closed GoogleCodeExporter closed 9 years ago
Could you please provide the code and the PO file that can reproduce the issue?
Thanks.
Original comment by qiang.xue
on 26 Feb 2010 at 3:04
The problem is that the current regex looks for message context (msgctxt) in
every
"record" like
msgctxt ""
msgid "Hello"
msgstr "REPLACED"
msgctxt ""
msgid "Hello2"
msgstr "REPLACED2"
So the regex should be changed so that the context msgctxt is optional
(enclosed in (
... )? in the regex) and the $matches index should be set appropriately...
here is the new load() function that works:
public function load($file,$context)
{
$pattern='/(msgctxt\s+"(.*?(?<!\\\\))")?'
. '\s+msgid\s+"(.*?(?<!\\\\))"'
. '\s+msgstr\s+"(.*?(?<!\\\\))"/';
$content=file_get_contents($file);
$n=preg_match_all($pattern,$content,$matches);
$messages=array();
for($i=0;$i<$n;++$i)
{
if($matches[2][$i]===$context)
{
$id=$this->decode($matches[3][$i]);
$message=$this->decode($matches[4][$i]);
$messages[$id]=$message;
}
}
return $messages;
}
PO file specification say that the msgctxt is optional... in Yii this is used
for the
context... so if you are using translations for different contexts than you
should
use the msgctxt on every record in this implementation as it is now...
Original comment by vadimg88@gmail.com
on 26 Feb 2010 at 4:11
This issue was closed by revision r1845.
Original comment by qiang.xue
on 27 Feb 2010 at 1:11
Thanks!
Original comment by qiang.xue
on 27 Feb 2010 at 1:12
Original issue reported on code.google.com by
vadimg88@gmail.com
on 24 Feb 2010 at 7:53