Java printf format strings in lookandfeel translation file
Albert Astals Cid
aacid at kde.org
Sat Mar 13 18:11:24 GMT 2021
El dissabte, 13 de març de 2021, a les 15:14:38 CET, Karl Ove Hufthammer va escriure:
> In the file plasma-workspace/plasma_lookandfeel_org.kde.lookandfeel.pot,
> there are several strings marked ‘java-printf-format’. Example:
>
> #: contents/components/Battery.qml:54
> #, java-printf-format
> msgid "Battery at %1%"
> msgstr ""
>
> For Norwegian Nynorsk, and probably other languages too, there needs be
> space between the number and the percentage. But if I write
>
> msgstr "Batterinivå %1 %"
>
> I get an error message (when running msgfmt):
>
> 'msgstr' is not a valid Java printf format string, unlike 'msgid'.
> Reason: In the directive number 1, the character ' ' is not a valid
> conversion specifier.
>
> How are we supposed to write the msgstr to get a valid PO file? And why
> are *Java* printf strings used inside QML files?
I guess someone mixed up Java with JavaScript that is the syntax most similar in terms of how the language is written for QML.
Problem is that if we switch to JavaScript the same relies, xgettext doesn't have a javascript+kde mode and still wants a printf-like string, so i've switched it to be C++, for now all strings are extracted properly and the marker is back to not requiring a printf-like format.
https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/711
Cheers,
Albert
>
> This file and kdeconnect-kde/plasma_applet_org.kde.kdeconnect.pot (which
> has the same problem) are the only two POT files that contain these
> types of strings.
>
>
>
More information about the kde-i18n-doc
mailing list