Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim tab characters from comment lines #215

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' );
}