-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
__d() doesn't take the correct msgstr depending on the position of the msgstr inside the .po file #10730
Comments
Is this related to #10597 ? Does the PR also fix this, or are those separate issues? |
@dereuromark I haven't tested the PR but after reading the issues comment history I think this pretty much is the same. |
There have been a few po file parsing changes since this was reported. Is this still an issue. |
Fixed in #11127 |
@markstory this is still an issue as reported today by @netstyler CakePHP 3.5.5. |
If I remove :
Then the following does take effect:
It shows then the plural version. It does not matter in which order I set the plural translations. Before or after the normal translations. |
@markstory I've added a test in a new branch https://github.com/cakephp/cakephp/tree/bug/plural-issues Check it out and run If I debug the $messages variable when running the test case I get this: ###########################
\src\I18n\Parser\PoFileParser.php (line 175)
########## DEBUG ##########
[
'Location' => [
'_context' => [
'' => 'Standort'
]
],
'Locations' => [
'_context' => [
'' => [
(int) 0 => 'Standort',
(int) 1 => 'Standorte'
]
]
]
] Compare this to the wa.po file contents: msgid "Location"
msgid_plural "Locations"
msgstr[0] "Standort"
msgstr[1] "Standorte"
msgid "Locations"
msgstr "Standorte" It looks like the current implementation makes the translation including the plurals available under the "Locations" key while it actually is "Location" in the po file. Also when debugging L115, the $item variable in parse(), I get this: ###########################
\src\I18n\Parser\PoFileParser.php (line 115)
########## DEBUG ##########
[
'ids' => [
'singular' => 'Locations'
],
'translated' => 'Standorte'
] Singular? It's the plural in both cases, the identifier string as the translated string as well are a plural. I'm really surprised nobody else encounter (or at least reported) this before. It's IMHO a major issue if you have an application that relies a lot on translated content. |
The message parsed on L115 is singular as it is a single message without plural forms attached. The parser can't look at the contents of message ids to guess whether they are singular or plural values. |
Copy pasting the internal ticket from my workmate @antoniosergio-moreira here. @netstyler
Original Problem
In the website's - www.german-architects.com - main navigation and in the Profiles navigation, the translation for the word "Projects" is only displaying "Projekt" and not "Projekte" (plural)
What we did at first
We checked the .po file for the word "Projects" and did not find anything. That was issue n.1. Issue n.2 is a bit trickier.
in
src/View/Helper/ProfileHelper.php
, line 75We added this word - "Projects" - as a msgstr to the
src/Locale/de/wa.po
file.At first, we added it in lines 297-298. Note that in lines 306-309 there is the singular/plural translation for Project/Projects. Having done this and cleared the cache, we note that the translations are not working in the website.
Addind the msgstr in lines 297-298
![screen shot 2017-06-07 at 10 16 00](https://user-images.githubusercontent.com/8680933/26868754-5ab27502-4b6a-11e7-9a4f-259531c85b78.png)
![screen shot 2017-06-07 at 10 17 38](https://user-images.githubusercontent.com/8680933/26868849-9c3dc5e4-4b6a-11e7-9ab4-656f3400c4e7.png)
In the website, translations are not accurate
What we did afterwards
Afterwards, we moved the msgstrs to the bottom of the
![screen shot 2017-06-07 at 10 29 59](https://user-images.githubusercontent.com/8680933/26869329-5679baac-4b6c-11e7-80f2-6f36e1733193.png)
![screen shot 2017-06-07 at 10 20 31](https://user-images.githubusercontent.com/8680933/26869050-4d9a26de-4b6b-11e7-8f78-77c7cd30bbea.png)
src/Locale/de/wa.po
file (lines 1934-1935). After clearing cache once again, we note that the translations in the frontend are now correct.Addind the msgstr in lines 1935-1936
In the website, translations are accurate
Seems it has something to do with the fact that if the msgstr are set before the singular/plural strings, this causes an issue - the msgstr isn't triggered or active or whatever the hell - and if the msgstr is set after the singular/plural strings, then all is well and everyone is smiling and happy and depression-free.
The text was updated successfully, but these errors were encountered: