/** * Tests parsing a file with larger plural forms * * @return void */ public function testParse2() { $parser = new MoFileParser(); $file = APP . 'Locale' . DS . 'rule_9_mo' . DS . 'core.mo'; $messages = $parser->parse($file); $this->assertCount(3, $messages); $expected = ['%d = 1 (from core)' => '%d is 1 (from core translated)', '%d = 0 or > 1 (from core)' => ['%d is 1 (from core translated)', '%d ends in 2-4, not 12-14 (from core translated)', '%d everything else (from core translated)'], 'Plural Rule 1 (from core)' => 'Plural Rule 9 (from core translated)']; $this->assertEquals($expected, $messages); }
/** * Tests parsing a file with plurals and message context * * @return void */ public function testParseFull() { $parser = new MoFileParser(); $file = APP . 'Locale' . DS . 'rule_0_mo' . DS . 'default.mo'; $messages = $parser->parse($file); $this->assertCount(5, $messages); $expected = ['Plural Rule 1' => 'Plural Rule 1 (translated)', '%d = 1' => ['_context' => ['This is the context' => 'First Context trasnlation', 'Another Context' => '%d = 1 (translated)']], '%d = 0 or > 1' => ['_context' => ['Another Context' => [0 => '%d = 1 (translated)', 1 => '%d = 0 or > 1 (translated)']]], '%-5d = 1' => '%-5d = 1 (translated)', '%-5d = 0 or > 1' => ['%-5d = 1 (translated)', '%-5d = 0 or > 1 (translated)']]; $this->assertEquals($expected, $messages); }