Skip to content

Commit

Permalink
Merge pull request #215 from ocean90/patch-1
Browse files Browse the repository at this point in the history
Trim tab characters from comment lines
  • Loading branch information
oscarotero authored Jul 15, 2019
2 parents aaf7d25 + 57c94a3 commit 81933e3
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Utils/ParsedComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function testPhpCode2()
'CONTEXT' => 'my-context',
],
]);
$countTranslations = 13;
$countTranslations = 14;
$countTranslated = 0;
$countHeaders = 8;

Expand Down
1 change: 1 addition & 0 deletions tests/assets/phpcode2/Csv.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ my-context,"All comments",
,"i18n tagged %s",
,foo,
,bar,
,"foo bar",
1 change: 1 addition & 0 deletions tests/assets/phpcode2/CsvDictionary.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ plain,
"i18n tagged %s",
foo,
bar,
"foo bar",
3 changes: 3 additions & 0 deletions tests/assets/phpcode2/Jed.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
],
"bar": [
""
],
"foo bar": [
""
]
}
}
3 changes: 3 additions & 0 deletions tests/assets/phpcode2/Json.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
],
"bar": [
""
],
"foo bar": [
""
]
},
"my-context": {
Expand Down
3 changes: 2 additions & 1 deletion tests/assets/phpcode2/JsonDictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"One comment": "",
"i18n tagged %s": "",
"foo": "",
"bar": ""
"bar": "",
"foo bar": ""
}
4 changes: 4 additions & 0 deletions tests/assets/phpcode2/PhpArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
array (
0 => '',
),
'foo bar' =>
array (
0 => '',
),
),
'my-context' =>
array (
Expand Down
5 changes: 5 additions & 0 deletions tests/assets/phpcode2/Po.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
11 changes: 11 additions & 0 deletions tests/assets/phpcode2/Xliff.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,16 @@
<target></target>
</segment>
</unit>
<unit id="327b6f07435811239bc47e1544353273">
<notes>
<note category="context"></note>
<note category="extracted-comment">translators: this comment is indented with a tab.</note>
<note category="reference">./tests/assets/phpcode2/input.php:51</note>
</notes>
<segment>
<source>foo bar</source>
<target></target>
</segment>
</unit>
</file>
</xliff>
1 change: 1 addition & 0 deletions tests/assets/phpcode2/Yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ messages:
'i18n tagged %s': ''
foo: ''
bar: ''
'foo bar': ''
my-context:
'All comments': ''
1 change: 1 addition & 0 deletions tests/assets/phpcode2/YamlDictionary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ plain: ''
'i18n tagged %s': ''
foo: ''
bar: ''
'foo bar': ''
10 changes: 9 additions & 1 deletion tests/assets/phpcode2/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@
*/
__( 'foo' );

/* translators: this should get extracted. */ $foo = __( 'bar' );
/* translators: this should get extracted. */ $foo = __( 'bar' );

function foo() {
/*
* translators: this comment is
* indented with a tab.
*/
__( 'foo bar' );
}

0 comments on commit 81933e3

Please sign in to comment.