js-shield
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about Weblate scripts


From: Ricardo Lafuente
Subject: Question about Weblate scripts
Date: Mon, 30 Oct 2023 12:06:13 +0000

Hi all,

We've been experimenting with Weblate for handling the website Markdown files. Even though their Markdown support is experimental, it's apparently doable. We created a component, website-faq (markdown requires a component per file) to try things out; apparently strings are extracted properly, but we still have to confirm whether the translations are properly applied back.

But we couldn't run the i18n helper scripts. First, there was a python error:

Traceback (most recent call last):
  File "/home/rlafuente/repos/jshelter/./tools/i18n/weblate2main.py", line 111, in <module>
    bl[key]["description"] == "" and "description" not in wl[key] and \
    ~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'description'

The KeyErrors can be dealt with by using .get() instead, so we made these changes which seemed to address the error:

             # Check if the only difference is a missing empty description
             if bl[key]["message"] == wl[key]["message"] and \
-                bl[key]["description"] == "" and "description" not in wl[key] and \ +                not bl[key].get("description") and "description" not in wl[key] and \                  (("placeholders" not in bl[key] and "placeholders" not in wl[key]) or \ -                (["placeholders"] in bl[key] and "placeholders" in wl[key] and \
-                bl[key]["placeholders"] == wl[key]["placeholders"])):
+                ("placeholders" in bl[key] and "placeholders" in wl[key] and \
+ bl[key].get("placeholders") == wl[key]["placeholders"])):
                     continue # Skip such strings

After the fix, running ./tools/i18n/weblate2main.py from the root repo directory gives out a string of failures:

I suppose that you have a branch weblate mirroring https://hosted.weblate.org/git/jshelter/webextension/. Make sure that your working tree is clear. Use git stash or similar commands if necessary.

Locales in current branch weblate
fr cs ru en
Press Enter to continue or exit with SIGINT (Ctrl+C)

Your branch is up to date with 'origin/weblate'.
patching file common/_locales/cs/messages.json
Hunk #1 FAILED at 85.
Hunk #2 FAILED at 164.
Hunk #3 FAILED at 192.
Hunk #4 FAILED at 200.
Hunk #5 FAILED at 223.
Hunk #6 FAILED at 245.
Hunk #7 FAILED at 294.
Hunk #8 FAILED at 319.
Hunk #9 FAILED at 355.
Hunk #10 FAILED at 446.
Hunk #11 FAILED at 624.
Hunk #12 FAILED at 661.
Hunk #13 FAILED at 781.
Hunk #14 FAILED at 833.
Hunk #15 FAILED at 845.
Hunk #16 FAILED at 877.
Hunk #17 FAILED at 939.
Hunk #18 FAILED at 955.
Hunk #19 FAILED at 971.
Hunk #20 FAILED at 995.
Hunk #21 FAILED at 1007.
Hunk #22 FAILED at 1059.
Hunk #23 FAILED at 1119.
Hunk #24 FAILED at 1131.
Hunk #25 FAILED at 1147.
Hunk #26 FAILED at 1163.
Hunk #27 FAILED at 1179.
Hunk #28 FAILED at 1187.
Hunk #29 FAILED at 1203.
Hunk #30 FAILED at 1355.
Hunk #31 FAILED at 1379.
Hunk #32 FAILED at 1391.
Hunk #33 FAILED at 1411.
33 out of 33 hunks FAILED -- saving rejects to file common/_locales/cs/messages.json.rej

----

At this point we could really use some guidance -- are the failures expected? Do they occur because of our changes to the weblate script?

Cheers,
A&R




reply via email to

[Prev in Thread] Current Thread [Next in Thread]