diff --git a/mycroft/skills/mycroft_skill/mycroft_skill.py b/mycroft/skills/mycroft_skill/mycroft_skill.py index 030017c026a8..8796b2e27d27 100644 --- a/mycroft/skills/mycroft_skill/mycroft_skill.py +++ b/mycroft/skills/mycroft_skill/mycroft_skill.py @@ -675,9 +675,22 @@ def find_resource(self, res_name, res_dirname=None): Returns: string: The full path to the resource file or None if not found """ + result = self._find_resource(res_name, self.lang, res_dirname) + if not result: + # when resource not found try fallback to en-us + LOG.warning( + "Resource '{}' for lang '{}' not found: trying 'en-us'" + .format(res_name, self.lang) + ) + result = self._find_resource(res_name, 'en-us', res_dirname) + return result + + def _find_resource(self, res_name, lang, res_dirname=None): + """Find resource by name, lang and dir + """ if res_dirname: # Try the old translated directory (dialog/vocab/regex) - path = join(self.root_dir, res_dirname, self.lang, res_name) + path = join(self.root_dir, res_dirname, lang, res_name) if exists(path): return path @@ -687,7 +700,7 @@ def find_resource(self, res_name, res_dirname=None): return path # New scheme: search for res_name under the 'locale' folder - root_path = join(self.root_dir, 'locale', self.lang) + root_path = join(self.root_dir, 'locale', lang) for path, _, files in walk(root_path): if res_name in files: return join(path, res_name)