Răsfoiți Sursa

Merge pull request #399 from namazuchin/feature/env-config-gui-lang

Byaidu 1 an în urmă
părinte
comite
79c09cdf2e
2 a modificat fișierele cu 24 adăugiri și 2 ștergeri
  1. 22 0
      docs/README_GUI.md
  2. 2 2
      pdf2zh/gui.py

+ 22 - 0
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
 
 <img src="./images/before.png" width="500"/>

+ 2 - 2
pdf2zh/gui.py

@@ -409,12 +409,12 @@ with gr.Blocks(
                 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(),