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

Fixing plural/singular issues in the po parser #11508

Merged
merged 3 commits into from
Dec 6, 2017
Merged

Conversation

burzum
Copy link
Contributor

@burzum burzum commented Dec 5, 2017

This will fix the case described here: #10730 (comment)

@burzum burzum requested a review from markstory December 5, 2017 17:00
@@ -65,39 +65,39 @@ public function testParse()
$expected = [
'Plural Rule 1' => [
'_context' => [
'' => 'Plural Rule 1 (translated)',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldnt revert the trailing commas IMO, just too much diff changes then that are none.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seriously? All the other lines haven't had one I think and AFAIK best practice by CS is to not have it there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No best practice (what the sniffer should be enforcing) is to always have the multiline trailing commas, to keep diffs low exactly for the reasons shown in this PR: Too much unrelated noise around the few lines of actual change.

Copy link
Contributor Author

@burzum burzum Dec 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They aren't used everywhere either here! https://github.com/cakephp/cakephp/blob/master/tests/TestCase/I18n/Parser/PoFileParserTest.php#L59-L102 So either remove them all or add them all!? However both ways will cause "noise".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in that case you can ignore my comment.

Copy link
Contributor Author

@burzum burzum Dec 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should agree on something and putt it into the coding standard? And then fix it everywhere in a separate PR. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but can then be unrelated to this PR.

@codecov-io
Copy link

codecov-io commented Dec 5, 2017

Codecov Report

Merging #11508 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #11508      +/-   ##
============================================
+ Coverage     93.37%    93.4%   +0.02%     
- Complexity    13021    13038      +17     
============================================
  Files           436      436              
  Lines         32755    32807      +52     
============================================
+ Hits          30586    30642      +56     
+ Misses         2169     2165       -4
Impacted Files Coverage Δ Complexity Δ
src/I18n/Parser/PoFileParser.php 100% <100%> (ø) 21 <0> (ø) ⬇️
src/I18n/Translator.php 100% <100%> (ø) 21 <0> (+3) ⬆️
src/ORM/BehaviorRegistry.php 100% <0%> (ø) 42% <0%> (+14%) ⬆️
src/Cache/Engine/FileEngine.php 90.1% <0%> (+1.09%) 73% <0%> (ø) ⬇️
src/Cache/CacheEngine.php 93.47% <0%> (+2.17%) 19% <0%> (ø) ⬇️
src/Cache/CacheRegistry.php 100% <0%> (+4.16%) 11% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9faa0f...0620c52. Read the comment docs.

'_context' => [
'Another Context' => [
0 => '%d = 1 (translated)',
1 => '%d = 0 or > 1 (translated)'
(int)0 => '%d = 1 (translated)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think you need the (int) cast here on the keys.

@@ -22,6 +22,8 @@
class Translator extends BaseTranslator
{

const PLURAL_PREFIX = 'p:';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have one copy of the constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, used the one here over the one in the parser.

$message = $this->getMessage(static::PLURAL_PREFIX . $key);
if (!$message) {
$message = $this->getMessage($key);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need this for backwards compatibilty and userland defined message loaders/parsers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly do you mean? Do I need to change something else here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I was just commenting on it for future us.

@markstory markstory added this to the 3.5.7 milestone Dec 5, 2017
@markstory markstory added the i18n label Dec 5, 2017
@markstory markstory merged commit b0f5a59 into master Dec 6, 2017
@markstory markstory deleted the bug/plural-issues branch December 6, 2017 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants