public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-i18n 2/2] fix strings with wrong format
Date: Wed, 04 Feb 2026 14:43:14 +0100	[thread overview]
Message-ID: <s8o4inw39ql.fsf@proxmox.com> (raw)
In-Reply-To: <20260204104150.178904-2-m.sandoval@proxmox.com> (Maximiliano Sandoval's message of "Wed, 4 Feb 2026 11:41:35 +0100")

Maximiliano Sandoval <m.sandoval@proxmox.com> writes:

> That would fail to be replaced at runtime. Depending on how the string
> was replaced at runtime having a broken format can result in either the
> string not being replaced at runtime or a crash.
>
> Where it was not clear how to fix the issue the string is left
> untranslated.
>
> After this commit the remaining errors are only in ukr.po, ru.po and a
> single error in pl.po that can be fixed with [2]. The reported errors in
> ukr.po and ru.po need more consideration due to the complexity of their
> plural forms.
>
> These were detected with the following script
>
> ```python
> import polib
> from pathlib import Path
>
> dirty = False
>
> def is_rust_format(entry):
>     return (
>         "{}" in entry.msgid
>         or "{0}" in entry.msgid
>         or "{n}" in entry.msgid
>         or "{}" in entry.msgid_plural
>         or "{0}" in entry.msgid_plural
>         or "{n}" in entry.msgid_plural
>     )
>
> def check_po_file(path):
>     po = polib.pofile(path)
>     for entry in po:
>         if "javascript-format" in entry.flags:
>             entry.flags.remove("javascript-format")
>
>         if (
>             entry.occurrences
>             and all([o.endswith(".rs") for (o, l) in entry.occurrences])
>             and is_rust_format(entry)
>         ):
>             entry.flags.append("rust-format")
>             dirty = True
>
>     if dirty:
>         po.save(f"{file.stem}.with-formats.po")
>
> root = Path()
>
> for file in root.iterdir():
>     if file.suffix == ".po" and ".with-formats" not in file.name:
>         check_po_file(file)
> ```
>
> which attaches the `rust-format` flag to a string. Then later the new po
> files are checked with
> ```
> msgfmt --check $PO_FILE
> ```
>
> with gettext 0.26. This can be done, for example, with
> ```sh
> for f in *.with-formats.po; do flatpak run --command=msgfmt --filesystem=home org.freedesktop.Platform//25.08 --check $f; done
> ```
>
> for example.
>
> [1] https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html#index-ngettext
> [2] https://lore.proxmox.com/all/20260204100736.134697-1-m.sandoval@proxmox.com/
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>

I found more issues on strings consumed by js. I will send v2 in a bit.

-- 
Maximiliano




  reply	other threads:[~2026-02-04 13:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 10:41 [PATCH proxmox-i18n 1/2] ja: remove second plural form Maximiliano Sandoval
2026-02-04 10:41 ` [PATCH proxmox-i18n 2/2] fix strings with wrong format Maximiliano Sandoval
2026-02-04 13:43   ` Maximiliano Sandoval [this message]
2026-02-04 13:50     ` superseded: " Maximiliano Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s8o4inw39ql.fsf@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal