Incorrect javascript-format on plasma-pa messages

Zayed Al-Saidi zayed.alsaidi at gmail.com
Thu Sep 17 07:00:19 BST 2026


I have the same issue with Arabic, as Arabic has a special percentage sign
(٪).
I have this entry in PO file:
#. +> trunk6 stable6 stable5
#: ListItemBase.qml:318 MicrophoneTestView.qml:215
#, javascript-format
#| msgctxt "volume percentage"
#| msgid "%1%"
msgctxt "volume percentage"
msgid "%1%"
msgstr "%1٪"

When I checked it with msgfmt, I got an error:
'msgstr' is not a valid JavaScript format string, unlike 'msgid'. Reason:
The character that terminates the directive number 1 is not a valid
conversion specifier.
msgfmt: found 1 fatal error

When I refer to gettext documentation [1] I see this:
16.3.7 JavaScript Format Strings
Although JavaScript specification itself does not define any format
strings, many JavaScript implementations provide printf-like functions.
xgettext understands a set of common format strings used in popular
JavaScript implementations including Gjs, Seed, and Node.JS. In such a
format string, a directive starts with ‘%’ and is finished by a specifier:
‘%’ denotes a literal percent sign, ‘c’ denotes a character, ‘s’ denotes a
string, ‘b’, ‘d’, ‘o’, ‘x’, ‘X’ denote an integer, ‘f’ denotes
floating-point number, ‘j’ denotes a JSON object.

Basically, % must be at the end of %1.

Is #, javascript-format a hard requirement?

1-
https://www.gnu.org/software/gettext/manual/gettext.html#JavaScript-Format-Strings


On Thu, Sep 17, 2026 at 5:11 AM Kisaragi Hiu <mail at kisaragi-hiu.com> wrote:

> I can reproduce this with Gettext 1.0.
>
> 1. Take the file with the "Volume at %1%" message
> https://invent.kde.org/plasma/plasma-pa/-/blob/master/applet/main.qml
> 2. Copy it to eg. /tmp/main.qml
> 3. Call the plasma-pa applet Messages.sh[1] in exactly the way Scripty
> calls it[2]:
>
>     # I've removed other flags irrelevant to this case for brevity
>     function kde_xgettext {
>         xgettext \
>             --from-code=UTF-8 \
>             -C --kde \
>             "$@"
>     }
>     # Based on the command from applet/Messages.sh but with the variable
> substituted for brevity & with paths replaced
>     kde_xgettext --language=JavaScript /tmp/main.qml -o /tmp/extracted.po
>
> 4. In this extracted file, "Volume at %1%" is indeed marked as
> javascript-format
> 5. Set its msgstr to have a space before the second %, like "Volume at %1
> %"
> 6. Checking the format does show the reported error
>
>     extracted.po:45: 'msgstr' is not a valid JavaScript format string,
> unlike 'msgid'. Reason: In the directive number 1, the character ' ' is not
> a valid conversion specifier.
>
> [1]: plasma-pa applet/Messages.sh
> https://invent.kde.org/plasma/plasma-pa/-/blob/10f9d903/applet/Messages.sh
> [2]: Scripty's update_translations sets XGETTEXT to the full path of
> xgettext then calls extract-messages.sh[3] which defines a kde_xgettext
> function. It then calls each Messages.sh with $XGETTEXT set to
> kde_xgettext, $XGETTEXT_PROGRAM set to xgettext, among other variables.
>      I wish this interface was documented in eg. Scripty's README and/or
> other places so developers who need to write Messages.sh would not have to
> just rely on copying magic around.
> [3]:
> https://invent.kde.org/sysadmin/l10n-scripty/-/blob/master/extract-messages.sh
>
>
> 2026/09/17 7:45 Harald Sitter <sitter at kde.org>:
>
> Hey!
>
> I've only had time for a quick glance but it looks to me like this may
> be a bug in gettext. Do we know which version of gettext is in use? Do
> we know the exact command it runs?
>
> on gettext 1.0 I utterly fail to reproduce the problem and also don't
> see how we would end up in the code that produces that error :/
>
>
> On Wed, Sep 16, 2026 at 6:40 PM Yoann Laissus <yoann.laissus at gmail.com>
> wrote:
> >
> > Hello,
> >
> > This morning, our daily scatter script failed due to SVN pre-commit
> hook:
> >>
> >> <stdin>:109: 'msgstr' is not a valid JavaScript format string, unlike
> 'msgid'. Reason: The character that terminates the directive number 1
> >> is not a valid conversion specifier
> >
> >
> > It's related to "javascript-format" added to some messages of plasma-pa.
> > The failed message (maybe others) is in
> plasma_applet_org.kde.plasma.volume.po :
> >>
> >> #: main.qml:96
> >> #, fuzzy, javascript-format
> >> #| msgid "Volume at %1%"
> >> msgid "Volume at %1%"
> >> msgstr "Volume à %1 %"
> >
> >
> > In French (and some other languages), we need to add a non-breaking
> space before %. It fails because msgfmt considers this invalid with
> "javascript-format".
> >
> > Last night, scripty changed a lot of format metadata in plasma-pa
> templates after a change to the gettext command (--language=JavaScript
> added to Messages.sh) :
> >
> https://invent.kde.org/plasma/plasma-pa/-/commit/10f9d90348eb59e1914d14da629dc1a21ad9cc2e
> > Template diff :
> https://invent.kde.org/localization/l10n-templates/-/commit/9fd452f8ecbe8df3e66a89657490005849746820?file_path=trunk6%2Fmessages%2Fplasma-pa%2Fplasma_applet_org.kde.plasma.volume.pot#line_a210c819d_115
> >
> > After some testing with gettext, "javascript-format" is added because of
> the trailing % in the message. There are multiple occurrences in the qml
> files of plasma-pa.
> >
> > I'm not really sure of the best way to fix it.
> > We could add some format override to gettext in Messages.sh or before
> the problematic i18n* calls but the problem can also appear on other
> projects using --language=JavaScript.
> >
> > What do you think ?
> >
> > Cheers,
> > --
> > Yoann Laissus
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-i18n-doc/attachments/20260917/39988dd9/attachment-0001.htm>


More information about the kde-i18n-doc mailing list