#37789 closed defect (bug) (worksforme)
Strange results in comment number declension
Reported by: | pavelevap | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | |
Focuses: | Cc: |
Description
We have first bug report with the fix in #13651.
Function: comments_popup_link("Komentáře (0)", "Komentáře (1)", "Komentáře (%)");
Strange results:
0 – Komentáře (0) 1 – Komentáře (1) 3 – 3 komentáře 9 – 9 komentářů
Change History (5)
#2
follow-up:
↓ 3
@
8 years ago
Thank you for creating new ticket :-)
It is not about translation. It is custom made theme with this function (without localization) and expected plural is Komentáře (%)
without declension. Throughout the whole theme there should be only Komentáře (number)
text, but there is default WP declension in effect (not wanted in this case).
It was also standard "hack" for previous bug and is commonly used now.
I can suggest our users for example gettext
filter to change on
to off
, but maybe this could be fixed somehow directly (when original string in comments_popup_link()
is not in English or without localization)?
#3
in reply to:
↑ 2
@
8 years ago
Replying to pavelevap:
I can suggest our users for example
gettext
filter to changeon
tooff
, but maybe this could be fixed somehow directly (when original string incomments_popup_link()
is not in English or without localization)?
Thanks for the clarification!
The problem is that get_comments_number_text()
doesn't know if the string is in English or not, it just takes any text or markup passed as the $more
argument and looks for the %
character followed (or preceded) by a word.
So if declension is not needed in certain cases, gettext
filter seems to be the appropriate way to disable it.
You could also use sprintf()
to insert the number yourself, that way string would not contain the %
character, and the supplied text will be used as is:
comments_popup_link( 'Komentáře (0)', 'Komentáře (1)', sprintf( 'Komentáře (%s)', number_format_i18n( get_comments_number() ) ) );
#4
@
8 years ago
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Closing, as the function works as expected, and there's a workaround to disable it for certain cases in comment:3.
Feel free to reopen if you think anything else should be done here.
Hi @pavelevap, thanks for the report!
What would be the expected results? As far as I can see, declension is working correctly for the last two strings (
3 komentáře
,9 komentářů
), the first two strings just need to be translated as0 komentářů
and1 komentář
.