Skip to content
Permalink
Browse files

Fix incorrectly parsed mo file context.

The context from mo files should be parsed correctly.

Refs #7118
  • Loading branch information...
markstory committed Jul 31, 2015
1 parent eddb2be commit a73fc25657d50de729a62946166f286d0f27565d
@@ -497,6 +497,9 @@ public static function loadMo($filename) {
$msgid = substr($data, $r["offs"], $r["len"]);
unset($msgid_plural);
if (strpos($msgid, "\x04") !== false) {
list($context, $msgid) = explode("\x04", $msgid);
}
if (strpos($msgid, "\000")) {
list($msgid, $msgid_plural) = explode("\000", $msgid);
}
@@ -508,9 +511,10 @@ public static function loadMo($filename) {
}
if ($msgid != '') {
$msgstr = array($context => $msgstr);
$translations[$msgid][$context] = $msgstr;
} else {
$translations[$msgid] = $msgstr;
}
$translations[$msgid] = $msgstr;
if (isset($msgid_plural)) {
$translations[$msgid_plural] =& $translations[$msgid];
@@ -2040,6 +2040,22 @@ public function testContext() {
$this->assertSame("saldo", __x('money', 'balance'));
}
/**
* Test basic context support using mo files.
*
* @return void
*/
public function testContextMoFile() {
Configure::write('Config.language', 'nld_mo');
$this->assertSame("brief", __x('mail', 'letter'));
$this->assertSame("letter", __x('character', 'letter'));
$this->assertSame("bal", __x('spherical object', 'ball'));
$this->assertSame("danspartij", __x('social gathering', 'ball'));
$this->assertSame("balans", __('balance'));
$this->assertSame("saldo", __x('money', 'balance'));
}
/**
* Singular method
*
Binary file not shown.

0 comments on commit a73fc25

Please sign in to comment.
You can’t perform that action at this time.