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)