On Fri, Jan 23, 2026 at 11:38 AM Benno Schulenberg <[email protected]> wrote:
> AttributeError: can't set attribute 'fuzzy' I don't get this error. polib is just a single file, I have version 1.2.0, this very exact file: https://github.com/izimobil/polib/blob/1.2.0/polib.py Can you please try replacing your polib with this one? I have python 3.13.7 (Ubuntu 25.10), in case this also makes a difference. If you can't get it working, I'd be happy to attach the result of my script, for all languages, in a tarball. > Commenting out that line makes the script succeed, and it reports: Well, not marking these autogenerated new strings as fuzzy will have consequences you're obviously aware of. > Looking at the --help strings for `wc`... > > msgid "" > " -c, --bytes\n" > " print the byte counts\n" > msgstr " -t, --text in tekstmodus lezen (standaard)\n" In these cases, the old translation is no longer present in the .po file, that's why my script couldn't recover them. Please see an updated version of the script. It takes three parameters, in this "chronological" order: - the old .po file, which you should grab from before the hyperlink change (e.g. from coreutils 9.9 tarball) - the current .po file - the output file It takes from the second file which translations need to be updated, but also uses the first file as "inspiration" to find a candidate translation. It resurrects 535 Dutch messages for me, including: #: src/wc.c:187 #, fuzzy msgid "" " -c, --bytes\n" " print the byte counts\n" msgstr "" " -t, --text in tekstmodus lezen (standaard)\n" "\n" "Met onderstaande opties kunt u kiezen welke aantallen weergeven worden,\n" "altijd in deze volgorde: regels, woorden, tekens, bytes, maximum regellengte.\n" "\n" " -c, --bytes het aantal bytes tonen\n" " -m, --chars het aantal tekens tonen\n" " -l, --lines het aantal regels tonen (in feite het aantal LF-tekens)\n" which, as I've stated in my previous mail (and is expected from this script), still needs to be cleaned up, but at least the previous translation is in there. > What a useful script should do: [...] > Not easy. What I'm aiming for is a reasonable compromise between developing that script vs. easing translator work. I hope I could get pretty close to that. Surely I could spend a week or two coming up with the perfect script perfectly extracting and reformatting all the translations, but I won't (and I guess no one else will). e.
#!/usr/bin/python3 # https://github.com/izimobil/polib/ # https://pypi.org/project/polib/ import polib import sys if len(sys.argv) != 4: print('Usage: coreutils-help-hyperlink-po-fixer-v2.py input-old-po-file input-current-po-file output-po-file\n') sys.exit(1) po0 = polib.pofile(sys.argv[1]) po1 = polib.pofile(sys.argv[2]) for entry in po0 + po1: entry.msgid_squeezed = " ".join(entry.msgid.split()) count = 0 for entry in po1: if entry.obsolete: continue if entry.msgstr != "" and not entry.fuzzy: continue if 'print the newline counts' in entry.msgid_squeezed: print('yup here') print(entry.msgid) print(entry.msgstr) found = False for e2 in po0 + po1: if len(entry.msgid_squeezed) < len(e2.msgid_squeezed) and entry.msgid_squeezed in e2.msgid_squeezed: entry.msgstr += e2.msgstr entry.fuzzy = True found = True break if found: count += 1 po1.save(sys.argv[3]) print(f'Resurrected {count} hopefully useful fuzzy translations')
