Skip to content

Commit 663d0bb

Browse files
authored
feat: translate login and account switch ui text (#26)
1 parent 8893956 commit 663d0bb

1 file changed

Lines changed: 32 additions & 26 deletions

File tree

fuo_ytmusic/provider_ui.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from fuo_ytmusic.qt_compat import (
1414
Dialog,
1515
QFormLayout,
16+
QInputDialog,
1617
QLabel,
1718
QLineEdit,
18-
QInputDialog,
1919
QPushButton,
2020
QVBoxLayout,
2121
TextSelectableByMouse,
@@ -37,7 +37,7 @@ def get_colorful_svg(self) -> str:
3737
return (Path(__file__).parent / "assets" / "icon.svg").as_posix()
3838

3939
def context_menu_add_items(self, menu):
40-
action = menu.addAction("切换账号")
40+
action = menu.addAction("Switch account")
4141
action.triggered.connect(lambda: aio.run_afn_ref(self.switch_profile_dialog))
4242

4343
def login_or_go_home(self):
@@ -59,15 +59,15 @@ def on_login_succeed(self):
5959

6060
async def switch_profile_dialog(self):
6161
if not provider.has_current_user():
62-
self._app.show_msg("请先登录后再切换账号")
62+
self._app.show_msg("Please log in before switching accounts.")
6363
return
6464
try:
6565
profiles = await aio.run_fn(provider.list_profiles)
6666
except Exception as e:
67-
self._app.show_msg(f"获取账号列表失败:{e}")
67+
self._app.show_msg(f"Failed to fetch account list: {e}")
6868
return
6969
if not profiles:
70-
self._app.show_msg("未获取到可用账号")
70+
self._app.show_msg("No available accounts found.")
7171
return
7272

7373
items = []
@@ -81,8 +81,8 @@ async def switch_profile_dialog(self):
8181

8282
selected, ok = QInputDialog.getItem(
8383
self._app,
84-
"切换账号",
85-
"选择账号",
84+
"Switch account",
85+
"Select an account",
8686
items,
8787
0,
8888
False,
@@ -95,9 +95,9 @@ async def switch_profile_dialog(self):
9595
try:
9696
await aio.run_fn(provider.switch_profile, profile.get("accountName"))
9797
except Exception as e:
98-
self._app.show_msg(f"切换账号失败:{e}")
98+
self._app.show_msg(f"Failed to switch account: {e}")
9999
return
100-
self._app.show_msg(f"已切换到:{profile.get('accountName')}")
100+
self._app.show_msg(f"Switched to: {profile.get('accountName')}")
101101
# Notify UI to refresh current user data/playlists.
102102
self.login_event.emit(self, 2)
103103

@@ -108,20 +108,20 @@ def __init__(self, provider):
108108

109109
self._provider = provider
110110

111-
self._login_btn = QPushButton("登录")
111+
self._login_btn = QPushButton("Login")
112112
self.__hint_label = QLabel(
113-
"欢迎来到 Youtube Music 登录界面 :)\n\n"
114-
"登录 Youtube Music 虽然繁琐,但一劳‘永逸’(因为认证信息的过期时间很长)。"
115-
"当然,不登录也可以使用 Youtube Music 的大部分功能,比如搜索、播放等。"
116-
"登录请按照下述指南操作:\n\n"
117-
"在浏览器中登录 Youtube Music,打开“开发者工具”,"
118-
"点击‘媒体库’按钮(这样会触发一个 POST 请求,这个请求通常会携带必要的认证信息),"
119-
"拷贝这个 HTTP 请求的 Authorization 和 Cookie 字段值并填入到表格中,点击登录按钮。"
113+
"Welcome to the YouTube Music sign-in dialog.\n\n"
114+
"1) Sign in on music.youtube.com in your browser.\n"
115+
"2) Open DevTools and trigger a request from Library.\n"
116+
"3) Copy Authorization and Cookie from that HTTP request.\n"
117+
"4) Paste them into the fields below, then click Login."
120118
)
121119
self.__progress_label = QLabel()
122120
self.__input_auth_header = QLineEdit()
123121
self.__input_cookies = QLineEdit()
124122
self.__hint_label.setTextInteractionFlags(TextSelectableByMouse)
123+
# Allow users to copy both onboarding hints and runtime status messages.
124+
self.__progress_label.setTextInteractionFlags(TextSelectableByMouse)
125125
self.__hint_label.setWordWrap(True)
126126
self.__progress_label.setWordWrap(True)
127127
self.setup_ui()
@@ -137,9 +137,9 @@ def setup_ui(self):
137137
)
138138

139139
self.__input_auth_header.setPlaceholderText(
140-
"类似:SAPISIDHASH 1765595295_abcd_u SAPISID1PHASH ..."
140+
"Example: SAPISIDHASH 1765595295_abcd_u SAPISID1PHASH ..."
141141
)
142-
self.__input_cookies.setPlaceholderText("请复制完整的值")
142+
self.__input_cookies.setPlaceholderText("Paste the full cookie value")
143143
form_layout.addRow("Authorization:", self.__input_auth_header)
144144
form_layout.addRow("Cookie:", self.__input_cookies)
145145
self._layout = QVBoxLayout(self)
@@ -157,30 +157,36 @@ async def login(self):
157157
auth = self.__input_auth_header.text()
158158
cookie = self.__input_cookies.text()
159159
if not (auth and cookie):
160-
self.show_progress("请输入 Authorization Cookie", color="red")
160+
self.show_progress("Please input Authorization and Cookie.", color="red")
161161
return
162162
self.generate_header_file(auth, cookie)
163-
self.show_progress("尝试登录...", color="green")
163+
self.show_progress("Trying to sign in...", color="green")
164164
await self.try_login()
165165

166166
async def try_auto_login(self):
167167
if HEADER_FILE.exists():
168-
self.show_progress("发现已存在的认证信息,尝试登录...", color="blue")
168+
self.show_progress(
169+
"Found existing credentials, trying to sign in...",
170+
color="blue",
171+
)
169172
await self.try_login()
170173
else:
171-
self.show_progress("等待用户填充认证信息...", color="blue")
174+
self.show_progress("Waiting for credentials...", color="blue")
172175

173176
async def try_login(self):
174177
try:
175178
user = await aio.run_fn(self._provider.try_get_user_with_headerfile)
176179
except Exception as e:
177-
self.show_progress(f"登录失败:{e}", color="red")
180+
self.show_progress(f"Sign-in failed: {e}", color="red")
178181
return
179182

180183
if user is None:
181-
self.show_progress("登录失败,可能是认证信息无效。", color="red")
184+
self.show_progress(
185+
"Sign-in failed: credentials may be invalid.",
186+
color="red",
187+
)
182188
return
183-
self.show_progress(f"登录成功,用户:{user.name}", color="green")
189+
self.show_progress(f"Signed in as: {user.name}", color="green")
184190
self._provider.auth(user)
185191
self.login_succeed.emit()
186192
self.hide()

0 commit comments

Comments
 (0)