mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-06-02 18:39:38 +00:00
Implement translations
This commit is contained in:
20
translate.py
20
translate.py
@@ -22,7 +22,16 @@ class StatusMessages(TypedDict):
|
||||
no_campaign: str
|
||||
|
||||
|
||||
class ChromeMessages(TypedDict):
|
||||
startup: str
|
||||
login_to_complete: str
|
||||
no_token: str
|
||||
closed_window: str
|
||||
|
||||
|
||||
class LoginMessages(TypedDict):
|
||||
chrome: ChromeMessages
|
||||
error_code: str
|
||||
unexpected_content: str
|
||||
email_code_required: str
|
||||
twofa_code_required: str
|
||||
@@ -219,6 +228,17 @@ default_translation: Translation = {
|
||||
"Unexpected content type returned, usually due to being redirected. "
|
||||
"Do you need to login for internet access?"
|
||||
),
|
||||
"chrome": {
|
||||
"startup": "Opening Chrome...",
|
||||
"login_to_complete": (
|
||||
"Complete the login procedure manually by pressing the Login button again."
|
||||
),
|
||||
"no_token": "No authorization token could be found.",
|
||||
"closed_window": (
|
||||
"Chrome window was closed before the login procedure could complete."
|
||||
),
|
||||
},
|
||||
"error_code": "Login error code: {error_code}",
|
||||
"incorrect_login_pass": "Incorrect username or password.",
|
||||
"incorrect_email_code": "Incorrect email code.",
|
||||
"incorrect_twofa_code": "Incorrect 2FA code.",
|
||||
|
||||
14
twitch.py
14
twitch.py
@@ -149,7 +149,7 @@ class _AuthState:
|
||||
loop = asyncio.get_running_loop()
|
||||
driver: Chrome | None = None
|
||||
while True:
|
||||
gui_print("Opening Chrome...")
|
||||
gui_print(_("login", "chrome", "startup"))
|
||||
try:
|
||||
version_main = None
|
||||
for attempt in range(2):
|
||||
@@ -230,9 +230,7 @@ class _AuthState:
|
||||
while driver.current_url != "https://www.twitch.tv/?no-reload=true":
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
gui_print(
|
||||
"Complete the login procedure manually by pressing the Login button again."
|
||||
)
|
||||
gui_print(_("login", "chrome", "login_to_complete"))
|
||||
await first_to_complete([
|
||||
url_waiter(),
|
||||
coro_unless_closed(login_form.wait_for_login_press()),
|
||||
@@ -257,11 +255,9 @@ class _AuthState:
|
||||
self.access_token = cookie["value"]
|
||||
break
|
||||
else:
|
||||
gui_print("Unable to extract authorization token")
|
||||
gui_print(_("login", "chrome", "no_token"))
|
||||
except WebDriverException:
|
||||
gui_print(
|
||||
"Chrome window was closed before the login procedure could complete."
|
||||
)
|
||||
gui_print(_("login", "chrome", "closed_window"))
|
||||
finally:
|
||||
if driver is not None:
|
||||
driver.quit()
|
||||
@@ -376,7 +372,7 @@ class _AuthState:
|
||||
# "error":"Please update your app to continue",
|
||||
# "error_description":"client blocked from this operation"
|
||||
# }
|
||||
gui_print(f"Login error code: {error_code}")
|
||||
gui_print(_("login", "error_code").format(error_code=error_code))
|
||||
logger.debug(str(login_response))
|
||||
use_chrome = True
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user