Skip to content

Commit 92e1ddf

Browse files
committed
fix: DEEPLのFreeプランでAPIを使うときはエンドポイントが違う問題を修正(チェックボックスにて選択)
1 parent 9573ded commit 92e1ddf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
QUESTS_DIR1 = Path('./kubejs/assets/kubejs/lang')
1717
QUESTS_DIR2 = Path('./kubejs/assets/ftbquests/lang')
1818
QUESTS_DIR3 = Path('./config/ftbquests/quests/chapters')
19-
DEEPL_API_URL = 'https://api.deepl.com/v2/translate'
20-
UPLOAD_URL = "https://api.deepl.com/v2/document"
21-
CHECK_STATUS_URL_TEMPLATE = "https://api.deepl.com/v2/document/{}"
22-
DOWNLOAD_URL_TEMPLATE = "https://api.deepl.com/v2/document/{}/result"
2319

2420
def extract_specific_file(zip_filepath, file_name, dest_dir):
2521
with zipfile.ZipFile(zip_filepath, 'r') as zip_ref:
@@ -445,6 +441,7 @@ def setup_logging(directory):
445441
[sg.Combo(select_options, default_value=select_options[2], key='target', size=(20, 1))],
446442
[sg.Text("DEEPL API KEY")],
447443
[sg.InputText(key='DEEPL_API_KEY')],
444+
[sg.Checkbox('Use Free API', default=True, key='free')],
448445
[sg.Button("Translate", key='translate')]
449446
]
450447

@@ -477,6 +474,12 @@ def setup_logging(directory):
477474
# 入力された値を取得
478475
target = values['target']
479476
API_KEY = values['DEEPL_API_KEY']
477+
suffix = "-free" if values['free'] else ""
478+
479+
DEEPL_API_URL = f'https://api.deepl.com/v2{suffix}/translate'
480+
UPLOAD_URL = f"https://api.deepl.com/v2{suffix}/document"
481+
CHECK_STATUS_URL_TEMPLATE = f"https://api.deepl.com/v2{suffix}/document/{{}}"
482+
DOWNLOAD_URL_TEMPLATE = f"https://api.deepl.com/v2{suffix}/document/{{}}/result"
480483

481484
try:
482485
if target == select_options[0]:

0 commit comments

Comments
 (0)