From 68d9f76f709a12ad7c3159d0acb08f9cad159426 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Fri, 12 Jul 2019 17:07:08 +0200 Subject: [PATCH 1/2] Trim tab characters from comment lines --- src/Utils/ParsedComment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/ParsedComment.php b/src/Utils/ParsedComment.php index 9fba6ae1..8844c403 100644 --- a/src/Utils/ParsedComment.php +++ b/src/Utils/ParsedComment.php @@ -59,8 +59,8 @@ public static function create($value, $line) return null; } - $line = ltrim($line, '#*/ '); - $line = rtrim($line, '#*/ '); + $line = ltrim($line, "#*/ \t"); + $line = rtrim($line, "#*/ \t"); return trim($line); }, explode("\n", $value)); From 57c94a31a70555282eca7b075ab4e0dd5ab2e59d Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Fri, 12 Jul 2019 22:25:23 +0200 Subject: [PATCH 2/2] Add test case --- tests/AssetsTest.php | 2 +- tests/assets/phpcode2/Csv.csv | 1 + tests/assets/phpcode2/CsvDictionary.csv | 1 + tests/assets/phpcode2/Jed.json | 3 +++ tests/assets/phpcode2/Json.json | 3 +++ tests/assets/phpcode2/JsonDictionary.json | 3 ++- tests/assets/phpcode2/PhpArray.php | 4 ++++ tests/assets/phpcode2/Po.po | 5 +++++ tests/assets/phpcode2/Xliff.xlf | 11 +++++++++++ tests/assets/phpcode2/Yaml.yml | 1 + tests/assets/phpcode2/YamlDictionary.yml | 1 + tests/assets/phpcode2/input.php | 10 +++++++++- 12 files changed, 42 insertions(+), 3 deletions(-) diff --git a/tests/AssetsTest.php b/tests/AssetsTest.php index 2b9b41bb..c304faa7 100644 --- a/tests/AssetsTest.php +++ b/tests/AssetsTest.php @@ -307,7 +307,7 @@ public function testPhpCode2() 'CONTEXT' => 'my-context', ], ]); - $countTranslations = 13; + $countTranslations = 14; $countTranslated = 0; $countHeaders = 8; diff --git a/tests/assets/phpcode2/Csv.csv b/tests/assets/phpcode2/Csv.csv index ca39bedf..07150eda 100644 --- a/tests/assets/phpcode2/Csv.csv +++ b/tests/assets/phpcode2/Csv.csv @@ -20,3 +20,4 @@ my-context,"All comments", ,"i18n tagged %s", ,foo, ,bar, +,"foo bar", diff --git a/tests/assets/phpcode2/CsvDictionary.csv b/tests/assets/phpcode2/CsvDictionary.csv index 6de2c98f..b63d0958 100644 --- a/tests/assets/phpcode2/CsvDictionary.csv +++ b/tests/assets/phpcode2/CsvDictionary.csv @@ -11,3 +11,4 @@ plain, "i18n tagged %s", foo, bar, +"foo bar", diff --git a/tests/assets/phpcode2/Jed.json b/tests/assets/phpcode2/Jed.json index 62af8ac8..a7a0e013 100644 --- a/tests/assets/phpcode2/Jed.json +++ b/tests/assets/phpcode2/Jed.json @@ -43,6 +43,9 @@ ], "bar": [ "" + ], + "foo bar": [ + "" ] } } \ No newline at end of file diff --git a/tests/assets/phpcode2/Json.json b/tests/assets/phpcode2/Json.json index 9ad0cc31..37b980c6 100644 --- a/tests/assets/phpcode2/Json.json +++ b/tests/assets/phpcode2/Json.json @@ -41,6 +41,9 @@ ], "bar": [ "" + ], + "foo bar": [ + "" ] }, "my-context": { diff --git a/tests/assets/phpcode2/JsonDictionary.json b/tests/assets/phpcode2/JsonDictionary.json index c20cbe39..855fef44 100644 --- a/tests/assets/phpcode2/JsonDictionary.json +++ b/tests/assets/phpcode2/JsonDictionary.json @@ -11,5 +11,6 @@ "One comment": "", "i18n tagged %s": "", "foo": "", - "bar": "" + "bar": "", + "foo bar": "" } \ No newline at end of file diff --git a/tests/assets/phpcode2/PhpArray.php b/tests/assets/phpcode2/PhpArray.php index f8787d23..598d5a13 100644 --- a/tests/assets/phpcode2/PhpArray.php +++ b/tests/assets/phpcode2/PhpArray.php @@ -65,6 +65,10 @@ array ( 0 => '', ), + 'foo bar' => + array ( + 0 => '', + ), ), 'my-context' => array ( diff --git a/tests/assets/phpcode2/Po.po b/tests/assets/phpcode2/Po.po index 4c9140ba..0addaf43 100644 --- a/tests/assets/phpcode2/Po.po +++ b/tests/assets/phpcode2/Po.po @@ -70,3 +70,8 @@ msgstr "" #: ./tests/assets/phpcode2/input.php:44 msgid "bar" msgstr "" + +#. translators: this comment is indented with a tab. +#: ./tests/assets/phpcode2/input.php:51 +msgid "foo bar" +msgstr "" diff --git a/tests/assets/phpcode2/Xliff.xlf b/tests/assets/phpcode2/Xliff.xlf index 3d9c17b7..b61e7194 100644 --- a/tests/assets/phpcode2/Xliff.xlf +++ b/tests/assets/phpcode2/Xliff.xlf @@ -149,5 +149,16 @@ + + + + translators: this comment is indented with a tab. + ./tests/assets/phpcode2/input.php:51 + + + foo bar + + + diff --git a/tests/assets/phpcode2/Yaml.yml b/tests/assets/phpcode2/Yaml.yml index a3e59f30..b3458ea2 100644 --- a/tests/assets/phpcode2/Yaml.yml +++ b/tests/assets/phpcode2/Yaml.yml @@ -16,5 +16,6 @@ messages: 'i18n tagged %s': '' foo: '' bar: '' + 'foo bar': '' my-context: 'All comments': '' diff --git a/tests/assets/phpcode2/YamlDictionary.yml b/tests/assets/phpcode2/YamlDictionary.yml index 854caaac..1d8a569b 100644 --- a/tests/assets/phpcode2/YamlDictionary.yml +++ b/tests/assets/phpcode2/YamlDictionary.yml @@ -11,3 +11,4 @@ plain: '' 'i18n tagged %s': '' foo: '' bar: '' +'foo bar': '' diff --git a/tests/assets/phpcode2/input.php b/tests/assets/phpcode2/input.php index 5d5ef9e1..76aede56 100644 --- a/tests/assets/phpcode2/input.php +++ b/tests/assets/phpcode2/input.php @@ -41,4 +41,12 @@ */ __( 'foo' ); -/* translators: this should get extracted. */ $foo = __( 'bar' ); \ No newline at end of file +/* translators: this should get extracted. */ $foo = __( 'bar' ); + +function foo() { + /* + * translators: this comment is + * indented with a tab. + */ + __( 'foo bar' ); +}