Maximiliano Sandoval <[email protected]> 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/[email protected]/ > > Signed-off-by: Maximiliano Sandoval <[email protected]>
I found more issues on strings consumed by js. I will send v2 in a bit. -- Maximiliano
