From ac34348513aad32096f2427b2f40d81d2d7a5cc4 Mon Sep 17 00:00:00 2001 From: "Carlos A. Crespo" Date: Sun, 1 Dec 2024 20:41:22 -0300 Subject: [PATCH] Workaround for issue #3324: Fix indentation issues caused by code snippets --- scripts/check_spell.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/check_spell.py b/scripts/check_spell.py index daf5feb3b6..d915d23849 100644 --- a/scripts/check_spell.py +++ b/scripts/check_spell.py @@ -7,6 +7,7 @@ import sys import tempfile +import polib import pospell @@ -44,7 +45,29 @@ def check_spell(po_files=None): if not po_files: po_files = Path(".").glob("*/*.po") - detected_errors = pospell.spell_check(po_files, personal_dict=output_filename, language="es_ES") + # Workaround issue #3324 FIXME + # It seems that all code snippets have line breaks '\n'. This causes the + # currently indentation issues. + + # Create temporary copies of the original files. + po_files_tmp = [] + for po_file in po_files: + with open(tempfile.mktemp(), "w") as temp_file: + # Copy content of the .po file + with open(po_file, "r", encoding="utf-8") as f: + temp_file.write(f.read()) + po_files_tmp.append(temp_file.name) + + # Don't translate probably code entries + polib_temp_file = polib.pofile(temp_file.name) + for entry in polib_temp_file: + if "\n" in entry.msgid: + entry.msgstr = "" + polib_temp_file.save() + + detected_errors = pospell.spell_check(po_files_tmp, personal_dict=output_filename, language="es_ES") + for tmp, orig in zip(po_files_tmp, po_files): + print(tmp, " == ", orig) return detected_errors pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy