Browse Source

Merge pull request #5009 from josbeir/3.0

Fix issue in PoFileParser where only slashes from translations of type array are stripped.
José Lorenzo Rodríguez 11 years ago
parent
commit
609ca19293
2 changed files with 16 additions and 1 deletions
  1. 3 1
      src/I18n/Parser/PoFileParser.php
  2. 13 0
      tests/TestCase/I18n/Parser/PoFileParserTest.php

+ 3 - 1
src/I18n/Parser/PoFileParser.php

@@ -134,9 +134,11 @@ class PoFileParser {
 		$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 {

+ 13 - 0
tests/TestCase/I18n/Parser/PoFileParserTest.php

@@ -73,4 +73,17 @@ class PoFileParserTest extends TestCase {
 		$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"']);
+	}
 }