From f89f4743ba1c01b12c0cb8eacd9e57e86897dfa8 Mon Sep 17 00:00:00 2001 From: namazu Date: Sat, 4 Jan 2025 10:25:04 +0900 Subject: [PATCH 1/2] add(gui): update default language settings to use environment variables --- pdf2zh/gui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf2zh/gui.py b/pdf2zh/gui.py index 0f6eb6c3..c941e962 100644 --- a/pdf2zh/gui.py +++ b/pdf2zh/gui.py @@ -409,12 +409,12 @@ def progress_bar(t: tqdm.tqdm): lang_from = gr.Dropdown( label="Translate from", choices=lang_map.keys(), - value="English", + value=os.getenv("PDF2ZH_LANG_FROM", "English"), ) lang_to = gr.Dropdown( label="Translate to", choices=lang_map.keys(), - value="Simplified Chinese", + value=os.getenv("PDF2ZH_LANG_TO", "Simplified Chinese"), ) page_range = gr.Radio( choices=page_map.keys(), From a1782b1813903f66175feba35337e7b4ca31b115 Mon Sep 17 00:00:00 2001 From: namazu Date: Sat, 4 Jan 2025 10:40:28 +0900 Subject: [PATCH 2/2] docs: enhance README_GUI with environment variable settings and supported languages --- docs/README_GUI.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/README_GUI.md b/docs/README_GUI.md index def28402..baa24d4e 100644 --- a/docs/README_GUI.md +++ b/docs/README_GUI.md @@ -8,6 +8,28 @@ This subfolder provides the GUI mode of `pdf2zh`. 2. Drop the PDF file into the window and click `Translate`. +### Environment Variables + +You can set the source and target languages using environment variables: + +- `PDF2ZH_LANG_FROM`: Sets the source language. Defaults to "English". +- `PDF2ZH_LANG_TO`: Sets the target language. Defaults to "Simplified Chinese". + +### Supported Languages + +The following languages are supported: + +- English +- Simplified Chinese +- Traditional Chinese +- French +- German +- Japanese +- Korean +- Russian +- Spanish +- Italian + ## Preview