Skip to content

Commit

Permalink
feat:standardize_lang_tag new utils
Browse files Browse the repository at this point in the history
ported from some TTS/STT plugins, will be useful across OVOS ecosystem
  • Loading branch information
JarbasAl committed Sep 16, 2024
1 parent 903b6d5 commit 748f7b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ovos_utils/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
from ovos_utils.file_utils import resolve_resource_file


def standardize_lang_tag(lang_code, macro=True):
"""https://langcodes-hickford.readthedocs.io/en/sphinx/index.html"""
try:
from langcodes import standardize_tag as std
return std(lang_code, macro=macro)
except:
if macro:
return lang_code.split("-")[0].lower()
return lang_code.lower()


def get_language_dir(base_path, lang="en-us"):
""" checks for all language variations and returns best path """
lang_path = join(base_path, lang)
Expand Down
1 change: 1 addition & 0 deletions requirements/extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ovos-plugin-manager>=0.0.25,<1.0.0
ovos-config>=0.0.12,<1.0.0
ovos-workshop>=0.0.13,<1.0.0
ovos_bus_client>=0.0.8,<1.0.0
langcodes

0 comments on commit 748f7b1

Please sign in to comment.