From 894235ad4b8eb038b6d69e3b76d2287e21b9702e Mon Sep 17 00:00:00 2001 From: Psychokiller1888 Date: Fri, 28 May 2021 14:18:58 +0200 Subject: [PATCH] Some support for #448 --- core/base/AssistantManager.py | 14 ++++++++++++++ core/base/model/Manager.py | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/core/base/AssistantManager.py b/core/base/AssistantManager.py index f6130f668..7a020ef12 100644 --- a/core/base/AssistantManager.py +++ b/core/base/AssistantManager.py @@ -278,3 +278,17 @@ def skillResource(self) -> Generator[Path, None, None]: continue yield resource + + + def switchLanguage(self, targetLang: str): + """ + Switches the assistant language to targetLang + :param targetLang: str, the language to switch to + :return: + """ + self.ConfigManager.updateAliceConfiguration(key='activeLanguage', value=targetLang) + self.LanguageManager.restart() + self.TalkManager.restart() + self.ASRManager.restart() + self.linkAssistant() + self.checkAssistant() diff --git a/core/base/model/Manager.py b/core/base/model/Manager.py index fed634f59..c1bc62dd9 100644 --- a/core/base/model/Manager.py +++ b/core/base/model/Manager.py @@ -86,6 +86,15 @@ def onStop(self): self._isActive = False + def restart(self): + """ + Stops and starts the manager + :return: + """ + self.onStop() + self.onStart() + + def _initDB(self): if self._databaseSchema: return SuperManager.getInstance().databaseManager.initDB(schema=self._databaseSchema, callerName=self.name)