Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Translation Languages via Environment Variables in the GUI #399

Merged
merged 2 commits into from
Jan 4, 2025
Merged
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
22 changes: 22 additions & 0 deletions docs/README_GUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
4 changes: 2 additions & 2 deletions pdf2zh/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading