Skip to content

Commit

Permalink
Merge pull request #5009 from josbeir/3.0
Browse files Browse the repository at this point in the history
Fix issue in PoFileParser where only slashes from translations of type array are stripped.
  • Loading branch information
lorenzo committed Oct 29, 2014
2 parents 1484357 + bf0cd7e commit 609ca19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/I18n/Parser/PoFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ protected function _addMessage(array &$messages, array $item) {
$translation = $item['translated'];

if (is_array($translation)) {
$translation = stripcslashes($translation[0]);
$translation = $translation[0];
}

$translation = stripcslashes($translation);

if ($context) {
$messages[$singular]['_context'][$context] = $translation;
} else {
Expand Down
13 changes: 13 additions & 0 deletions tests/TestCase/I18n/Parser/PoFileParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,17 @@ public function testParseMultiLine() {
$this->assertCount(12, $messages);
$this->assertTextEquals("v\nsecond line", $messages["valid\nsecond line"]);
}

/**
* Test parsing a file with quoted strings
*
* @return void
*/
public function testQuotedString() {
$parser = new PoFileParser;
$file = APP . 'Locale' . DS . 'en' . DS . 'default.po';
$messages = $parser->parse($file);

$this->assertTextEquals('this is a "quoted string" (translated)', $messages['this is a "quoted string"']);
}
}

0 comments on commit 609ca19

Please sign in to comment.