|
7 | 7 | import sys
|
8 | 8 | import tempfile
|
9 | 9 |
|
| 10 | +import polib |
10 | 11 | import pospell
|
11 | 12 |
|
12 | 13 |
|
@@ -44,7 +45,29 @@ def check_spell(po_files=None):
|
44 | 45 | if not po_files:
|
45 | 46 | po_files = Path(".").glob("*/*.po")
|
46 | 47 |
|
47 |
| - detected_errors = pospell.spell_check(po_files, personal_dict=output_filename, language="es_ES") |
| 48 | + # Workaround issue #3324 FIXME |
| 49 | + # It seems that all code snippets have line breaks '\n'. This causes the |
| 50 | + # currently indentation issues. |
| 51 | + |
| 52 | + # Create temporary copies of the original files. |
| 53 | + po_files_tmp = [] |
| 54 | + for po_file in po_files: |
| 55 | + with open(tempfile.mktemp(), "w") as temp_file: |
| 56 | + # Copy content of the .po file |
| 57 | + with open(po_file, "r", encoding="utf-8") as f: |
| 58 | + temp_file.write(f.read()) |
| 59 | + po_files_tmp.append(temp_file.name) |
| 60 | + |
| 61 | + # Don't translate probably code entries |
| 62 | + polib_temp_file = polib.pofile(temp_file.name) |
| 63 | + for entry in polib_temp_file: |
| 64 | + if "\n" in entry.msgid: |
| 65 | + entry.msgstr = "" |
| 66 | + polib_temp_file.save() |
| 67 | + |
| 68 | + detected_errors = pospell.spell_check(po_files_tmp, personal_dict=output_filename, language="es_ES") |
| 69 | + for tmp, orig in zip(po_files_tmp, po_files): |
| 70 | + print(tmp, " == ", orig) |
48 | 71 | return detected_errors
|
49 | 72 |
|
50 | 73 |
|
|
0 commit comments