From 1b836c373edcd154d2f709d4352a5257d2637a19 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Fri, 18 Oct 2024 02:22:18 +0100 Subject: [PATCH] fix:lingua_franca (#257) lingua franca requires lowercased lang codes, which causes ask_yesno to fail adds better dialect support --- ovos_workshop/skills/ovos.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ovos_workshop/skills/ovos.py b/ovos_workshop/skills/ovos.py index 8cffdad8..ad9c2d86 100644 --- a/ovos_workshop/skills/ovos.py +++ b/ovos_workshop/skills/ovos.py @@ -1999,7 +1999,17 @@ def ask_yesno(self, prompt: str, 'no', including a response of None. """ resp = self.get_response(dialog=prompt, data=data) - answer = yes_or_no(resp, lang=self.lang) if resp else resp + # TODO - lingua_franca does not support standardized lang tags + # deprecate it, use a plugin here https://github.com/TigreGotico/ovos-solver-YesNo-plugin + lf_langs = ("az-az", "ca-es", "cs-cz", "da-dk", "de-de", + "en-us", "es-es", "fr-fr", + "hu-hu", "it-it", "nl-nl", "pl-pl", + "fa-ir", "pt-pt", "ru-ru", "sl-si", + "sv-se", "tr-tr", "eu-eu", "uk-ua") + lang, score = closest_match(self.lang, lf_langs) + if score > 10: + lang = self.lang # let it raise a value Error in next line + answer = yes_or_no(resp, lang=lang) if resp else resp if answer is True: return "yes" elif answer is False: