Plural forms in the style KCM
Freek de Kruijf
freekdekruijf at kde.nl
Wed Sep 2 09:22:50 BST 2026
Op woensdag 2 september 2026 10:18:46 Midden-Europese zomertijd schreef
Kisaragi Hiu:
> Good day,
>
>
> AFAIK this should still work for any language.
>
> https://invent.kde.org/plasma/plasma-workspace/-/blob/master/kcms/style/
> kcmstyle.cpp?ref_type=heads#L225:
>
> message = i18ncp("@info:status",
> "Successfully uninstalled “%2” but could not
> uninstall others:\n",
> "Successfully uninstalled %1 styles but could
> not uninstall others:\n",
> uninstalled.size(),
> uninstalled.first());
>
> i18ncp uses the first integer-valued argument as the number that is plugged
> into the plural forms expression. That expression is decided by the
> particular PO file and does not assume Germatic plurals.
> https://invent.kde.org/frameworks/ki18n/-/blob/master/docs/programmers-guid
> e.md#gen_usage:~:text=The%20plural%20form%20is%20decided%20by%20the%20first%
> 20integer%2Dvalued%20argument
>
>
> (note: a guide should not be the only place some information is documented,
> but right now the ki18n documentation does not mention this fact in the
> reference docs, only in this guide. I might try to open an MR for this...)
>
>
> So, the size is passed into the plural-forms expression of the target
> language to decide which msgstr to use, in addition to being the value to
> fill into the %1 placeholder.
>
>
> So it should still work fine with non-Germatic languages no matter how
> complicated the plural-forms expression is.
>
>
> (Gettext does assume 1 or 2 plurals for source text, which is one of the
> only issues that Gettext has. This means while it supports translating into
> any language correctly, it only supports translating from languages with 1
> or 2 plurals correctly. This is fine in KDE since we're translating from
> English, but the issue does exist.)
>
>
> Best regards,
> Kisaragi Hiu
Below is the error message about not accepting the translation:
Committing transaction...
svn: E165001: Commit failed (details follow):
svn: E165001: Commit blocked by pre-commit hook (exit code 1) with output:
<stdin>:132: a format specification for argument 2, as in 'msgstr[0]', doesn't
exist in 'msgid_plural'
<stdin>:140: a format specification for argument 2, as in 'msgstr[0]', doesn't
exist in 'msgid_plural'
msgfmt: found 2 fatal errors
trunk/l10n-kf6/nl/messages/plasma-workspace/kcm_style.po:
ERROR: There were syntax errors detected in a po file you committed.
ERROR: Please correct them first.
--
vr.gr.
Freek de Kruijf
vertaler/coördinator van KDE
More information about the kde-i18n-doc
mailing list