Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add Thai GUI language option
  • Loading branch information
Wenjunyun123 committed Jun 26, 2026
commit 857a5b6edf843584c94ce231796380e58f81bbd1
1 change: 1 addition & 0 deletions docs/README_GUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The following languages are supported:
- Russian
- Spanish
- Italian
- Thai

## Preview

Expand Down
1 change: 1 addition & 0 deletions pdf2zh/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __getattr__(self, name):
"Russian": "ru",
"Spanish": "es",
"Italian": "it",
"Thai": "th",
}

# The following variable associate strings with page ranges
Expand Down
1 change: 1 addition & 0 deletions pdf2zh/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ def lang_mapping(input_lang: str) -> str:
"ru": "Russian",
"es": "Spanish",
"it": "Italian",
"th": "Thai",
}

return langdict[input_lang]
Expand Down
25 changes: 25 additions & 0 deletions test/test_gui_languages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ast
from pathlib import Path


def _load_gui_lang_map() -> dict[str, str]:
gui_path = Path(__file__).resolve().parents[1] / "pdf2zh" / "gui.py"
module = ast.parse(gui_path.read_text(encoding="utf-8"))

for node in module.body:
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "lang_map":
return ast.literal_eval(node.value)

raise AssertionError("lang_map not found in pdf2zh/gui.py")


def test_gui_language_map_includes_thai():
assert _load_gui_lang_map()["Thai"] == "th"


def test_qwen_mt_maps_thai_language_code():
from pdf2zh.translator import QwenMtTranslator

assert QwenMtTranslator.lang_mapping("th") == "Thai"