From f4f6c7a6d8d0703f21558695f21e891835e3dd32 Mon Sep 17 00:00:00 2001 From: Harsh Sharma <94862735+harshsharma1506@users.noreply.github.com> Date: Sat, 30 May 2026 21:53:52 +0530 Subject: [PATCH 1/2] Handle lone '%' translation strings without parser exceptions Entries consisting solely of '%' currently emit: Error parsing msgid at index 0: string index out of range Error parsing msgstr at index 0: string index out of range Validation still completes successfully, but the parser emits confusing terminal output. --- usr/bin/mint-check-translations | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/usr/bin/mint-check-translations b/usr/bin/mint-check-translations index 7a815d7..d98d768 100755 --- a/usr/bin/mint-check-translations +++ b/usr/bin/mint-check-translations @@ -245,7 +245,7 @@ class Main: if issue_found: self.add_issue_to_treeview(mo, mo.project, msgid, msgstr, res, mo.current_index) mo.current_index += 1 - + def check_entry(self, msgid, msgstr, is_plural=False, is_python=False): msgid = msgid.replace("%%", " ") msgstr = msgstr.replace("%%", " ") @@ -263,6 +263,11 @@ class Main: if idx > 1 and msgid[idx-1] == " " and msgid[idx-2] in DIGITS: # ignore this token, it's probably a percentage continue + if idx == 0 and len(msgid) == 1: + # Handle entries consisting solely of '%' to avoid + # indexing beyond the end of the string while parsing + # formatting placeholders. + continue if idx > -1 and msgid[idx-1] != "\\": subidx = 0 if msgid[idx+1] == "(": @@ -297,6 +302,11 @@ class Main: if idx > 1 and msgstr[idx-1] == " " and msgstr[idx-2] in DIGITS: # ignore this token, it's probably a percentage continue + if idx == 0 and len(msgstr) == 1: + # Handle entries consisting solely of '%' to avoid + # indexing beyond the end of the string while parsing + # formatting placeholders. + continue if idx > -1 and msgstr[idx-1] != "\\": subidx = 0 if msgstr[idx+1] == "(": @@ -321,7 +331,7 @@ class Main: break except Exception as e: print("Error parsing msgstr at index %d: %s" % (idx, e)) - + for keyword in ["5%", "0%"]: if keyword in msgid: # Ignore percentages From c5c27deb41c60c47b2d71ef140a178c37650654c Mon Sep 17 00:00:00 2001 From: Harsh Sharma <94862735+harshsharma1506@users.noreply.github.com> Date: Sat, 30 May 2026 22:18:01 +0530 Subject: [PATCH 2/2] Handle lone '%' translation strings without parser exceptions cleaned it a bit. --- usr/bin/mint-check-translations | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/bin/mint-check-translations b/usr/bin/mint-check-translations index d98d768..1ef5def 100755 --- a/usr/bin/mint-check-translations +++ b/usr/bin/mint-check-translations @@ -245,7 +245,7 @@ class Main: if issue_found: self.add_issue_to_treeview(mo, mo.project, msgid, msgstr, res, mo.current_index) mo.current_index += 1 - + def check_entry(self, msgid, msgstr, is_plural=False, is_python=False): msgid = msgid.replace("%%", " ") msgstr = msgstr.replace("%%", " ") @@ -331,7 +331,7 @@ class Main: break except Exception as e: print("Error parsing msgstr at index %d: %s" % (idx, e)) - + for keyword in ["5%", "0%"]: if keyword in msgid: # Ignore percentages