mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-04 10:32:40 +00:00
Merge pull request #7147 from cakephp/issue-7118
Fix incorrectly parsed mo file context.
This commit is contained in:
commit
b89ac18e55
3 changed files with 22 additions and 2 deletions
|
@ -497,6 +497,9 @@ class I18n {
|
|||
$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 @@ class I18n {
|
|||
}
|
||||
|
||||
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 @@ class I18nTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
BIN
lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo
Normal file
BIN
lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue