From 5b1089e3cca524ef73c0c02a6ba8112ae7201c55 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Fri, 19 Aug 2022 10:18:41 +0200 Subject: [PATCH] Add the terminated status in the gui --- lang/简体中文.json | 3 ++- main.py | 1 + translate.py | 6 ++++-- twitch.py | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lang/简体中文.json b/lang/简体中文.json index 0220c2c..5697cc3 100644 --- a/lang/简体中文.json +++ b/lang/简体中文.json @@ -1,6 +1,5 @@ { "status": { - "exiting": "正在退出...", "terminated": "\n应用程序已终止,请关闭窗口以退出应用程序。", "goes_online": "{channel} 该频道已上线, 正在切换...", "goes_offline": "{channel} 该频道已离线, 正在切换...", @@ -28,6 +27,8 @@ "status": { "name": "状态", "idle": "已完成获取", + "exiting": "正在退出...", + "terminated": "应用已终止运行", "cleanup": "清除频道中...", "gathering": "搜索直播频道...", "switching": "切换直播频道中...", diff --git a/main.py b/main.py index 9ad05c2..691c07b 100644 --- a/main.py +++ b/main.py @@ -181,6 +181,7 @@ finally: loop.run_until_complete(client.shutdown()) if not client.gui.close_requested: client.print(_("status", "terminated")) + client.gui.status.update(_("gui", "status", "terminated")) loop.run_until_complete(client.gui.wait_until_closed()) # save the application state # NOTE: we have to do it after wait_until_closed, diff --git a/translate.py b/translate.py index 0b2f3ed..3a67068 100644 --- a/translate.py +++ b/translate.py @@ -11,7 +11,6 @@ if TYPE_CHECKING: class StatusMessages(TypedDict): - exiting: str terminated: str goes_online: str goes_offline: str @@ -40,6 +39,8 @@ class ErrorMessages(TypedDict): class GUIStatus(TypedDict): name: str idle: str + exiting: str + terminated: str cleanup: str gathering: str switching: str @@ -202,7 +203,6 @@ class Translation(TypedDict): default_translation: Translation = { "status": { - "exiting": "Exiting...", "terminated": "\nApplication Terminated.\nClose the window to exit the application.", "goes_online": "{channel} goes ONLINE, switching...", "goes_offline": "{channel} goes OFFLINE, switching...", @@ -233,6 +233,8 @@ default_translation: Translation = { "status": { "name": "Status", "idle": "Idle", + "exiting": "Exiting...", + "terminated": "Terminated", "watching": "Watching {channel}", "cleanup": "Cleaning up channels...", "gathering": "Gathering channels...", diff --git a/twitch.py b/twitch.py index 52b94e5..df97d2d 100644 --- a/twitch.py +++ b/twitch.py @@ -88,7 +88,7 @@ class Twitch: async def shutdown(self) -> None: start_time = time() - self.gui.print(_("status", "exiting")) + self.gui.print(_("gui", "status", "exiting")) self.stop_watching() if self._watching_task is not None: self._watching_task.cancel() @@ -394,7 +394,7 @@ class Twitch: # break the state change chain by clearing the flag self._state_change.clear() elif self._state is State.EXIT: - self.gui.status.update(_("status", "exiting")) + self.gui.status.update(_("gui", "status", "exiting")) # we've been requested to exit the application break await self._state_change.wait()