Search & Replace: show number of checked items in the header row
Alex
neundorf | Apr 18 2018, 7:55 PM |
This commit broke i18n: the translated gettext files because the difference in the number of placeholders between the single and the plural(s) form(s) can't be more than one. If there are 3 placeholders (%1, %2, %3) in the plural form, there should be two in the singular form.
msgfmt complains with tons of messages like:
<stdin>:133: a format specification for arguments 1 and 2 doesn't exist in 'msgstr[0]', only one argument may be ignored
<stdin>:151: a format specification for arguments 1 and 2 doesn't exist in 'msgstr[0]', only one argument may be ignored
<stdin>:169: a format specification for arguments 1 and 3 doesn't exist in 'msgstr[0]', only one argument may be ignored
<stdin>:187: a format specification for arguments 1 and 4 doesn't exist in 'msgstr[0]', only one argument may be ignored
<stdin>:207: a format specification for arguments 1 and 3 doesn't exist in 'msgstr[0]', only one argument may be ignored
and we can't commit translations unless we change them to include the additional placeholder. Please fix in the original message.
This is the call:
i18np("<b><i>One match found in folder %2</i></b>",
"<b><i>%1 matches (%3 checked) found in folder %2</i></b>", m_curResults->matches, m_resultBaseDir, checkedItemCount));
which gives either
"One match found in folder /tmp/"
or plural
"20 matches (5 checked) found in folder /tmp/"
So how do I do that properly so that i18n() works ?
Thanks in advance
Alex
There difference of placeholders between the singular and the plural form should be at least 1. So the singular form should have %2 or %3.
It was discussed a bit here: https://mail.kde.org/pipermail/kde-doc-english/2018-April/017693.html
@ilic , do you know anything more about this issue?
First try to fix it:
https://commits.kde.org/kate/bd321190aedfcd4a3a19f215abf13cd3e135138f
Alex
Well that would work technically, but it is somewhat confusing. In principle, plural call should not be used as a generic "if" on number, but only there where trully the only difference in wording is in the number. So the canonical fix would be to have if-condition on m_curResults->matches under each case in the switch statement, with one branch i18n() call (no "(checked ...)") and the other i18np() call.
The i18np("unused", "%1 checked", checkedItemCount) should still remain though for multiple plurals, but as i18npc("inserted as %2 into subsequent messages", "%1 checked", "%1 checked", checkedItemCount).
Where can I find documentation about that "context" ?
In the docs for i18n(), i18np(), i18nc() etc. it is just mentioned that there
is a context parameter but not what that is or how it should be used.
Could I simply do the following ?
if (matches <= 1)
i18n("One item found);
else
i18n("%1 items found (%2 checked) in directory %3", matched, checked, dir);
Alex