summaryrefslogtreecommitdiff
path: root/ledit
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2024-08-30 17:43:22 -0300
committerJesusaves <cpntb1@ymail.com>2024-08-30 17:43:22 -0300
commit6a97526935a0c89761d6ce57d638e40b5e2aa8cd (patch)
tree2507011caed1d22238a561e383f626a678dd9299 /ledit
parent43a260e191d39b0d45c89d21ce9014aaa8017c1d (diff)
downloadtools-6a97526935a0c89761d6ce57d638e40b5e2aa8cd.tar.gz
tools-6a97526935a0c89761d6ce57d638e40b5e2aa8cd.tar.bz2
tools-6a97526935a0c89761d6ce57d638e40b5e2aa8cd.tar.xz
tools-6a97526935a0c89761d6ce57d638e40b5e2aa8cd.zip
Replace googletrans with deep_translator in L'Edit.
This also allows users to use ChatGpt or DeepL if they wish.
Diffstat (limited to 'ledit')
-rwxr-xr-xledit/ledit.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/ledit/ledit.py b/ledit/ledit.py
index b335dab..6375400 100755
--- a/ledit/ledit.py
+++ b/ledit/ledit.py
@@ -8,7 +8,8 @@
import requests, json, traceback, subprocess, sys, time, os, uuid, base64
import zipfile, shutil, webbrowser
import polib
-from googletrans import Translator
+#from googletrans import Translator
+from deep_translator import GoogleTranslator # ChatGptTranslator, DeeplTranslator
import tkinter as tk
from tkinter.messagebox import showinfo, showerror, askyesno
from functools import partial
@@ -52,7 +53,7 @@ def open_url(link, *etc):
return
## Only meaningful on Linux, or base things
-ttl=Translator()
+#ttl=Translator()
os.environ["APPIMAGELAUNCHER_DISABLE"]="1"
## Retrieve file name
@@ -67,8 +68,11 @@ if len(sys.argv) >= 3:
else:
ln = "pt_BR"
+## With deep_tl we need to pass this later
+ttl=GoogleTranslator(source="en", target=ln.split("_")[0])
+
## Open the PO file and report current completion
-print("Opening \"%s\"... #0 is female, #1 is male", fn)
+print("Opening \"%s\"...", fn)
po=polib.pofile(fn)
cnt=0
print("Current progress: "+str(po.percent_translated())+"%")
@@ -76,7 +80,7 @@ print("Current progress: "+str(po.percent_translated())+"%")
## Define the scopes, they should be completed in order
scope_list=[("Nard Ship", "npc/002-", "npc/000-"),
("Candor", "npc/005-", "npc/006-2"),
- ("Databases", "db/", "npc/functions", "npc/items", "npc/config", "npc/craft", "npc/016-", "item_db", "mob_db"),
+ ("Databases", "db/", "npc/functions", "npc/items", "npc/config", "npc/craft", "npc/016-"),
("Tonori", "npc/003-", "npc/004-", "npc/007-"),
("Hurnscald", "npc/012-", "npc/013-", "npc/014-", "npc/015-"),
("Halinarzo", "npc/009-", "npc/010-", "npc/011-"),
@@ -132,10 +136,8 @@ def save(widget):
translated=translated.replace('\r','')
if translated.endswith("\n"):
translated=translated[:-1]
- ## ...Or don't, if it is already blank (...not really needed)
- if (translated.strip() != ""):
- print("»" + translated)
- polist[0].msgstr=translated
+ print("»" + translated)
+ polist[0].msgstr=translated
polist.pop(0)
po.save()
cnt+=1
@@ -208,7 +210,8 @@ def _build_screen(destroy=False):
## Add the translation text
entry1 = tk.Text(root, state="normal", width=50, height=3, background="#0c2241", foreground="#fff", wrap="word")
try:
- entry1.insert("end", ttl.translate(str(e.msgid), src='en', dest='pt_BR').text)
+ #entry1.insert("end", ttl.translate(str(e.msgid), src='en', dest=ln).text)
+ entry1.insert("end", ttl.translate(str(e.msgid)))
except:
traceback.print_exc()
pass