Skip to content

Commit

Permalink
Merge pull request #284 from OpenVoiceOS/release-0.3.5a1
Browse files Browse the repository at this point in the history
Release 0.3.5a1
  • Loading branch information
JarbasAl authored Oct 16, 2024
2 parents 924c2f2 + ce326be commit 0978d47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changelog

## [0.3.4a1](https://github.com/OpenVoiceOS/ovos-utils/tree/0.3.4a1) (2024-10-16)
## [0.3.5a1](https://github.com/OpenVoiceOS/ovos-utils/tree/0.3.5a1) (2024-10-16)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-utils/compare/0.3.3...0.3.4a1)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-utils/compare/0.3.4...0.3.5a1)

**Merged pull requests:**

- fix:standardize\_lang [\#281](https://github.com/OpenVoiceOS/ovos-utils/pull/281) ([JarbasAl](https://github.com/JarbasAl))
- fix:standardize\_lang [\#283](https://github.com/OpenVoiceOS/ovos-utils/pull/283) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
18 changes: 11 additions & 7 deletions ovos_utils/lang/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from os import listdir
from os.path import isdir, join
from langcodes import tag_distance, standardize_tag as std
from typing import Optional

from langcodes import tag_distance, standardize_tag as std

from ovos_utils.file_utils import resolve_resource_file


def standardize_lang_tag(lang_code, macro=True):
def standardize_lang_tag(lang_code: str, macro=True) -> str:
"""https://langcodes-hickford.readthedocs.io/en/sphinx/index.html"""
try:
return std(lang_code, macro=macro)
return str(std(lang_code, macro=macro))
except:
if macro:
return lang_code.split("-")[0].lower()
Expand All @@ -17,7 +20,7 @@ def standardize_lang_tag(lang_code, macro=True):
return lang_code.lower()


def get_language_dir(base_path, lang="en-US"):
def get_language_dir(base_path: str, lang: str ="en-US") -> Optional[str]:
""" checks for all language variations and returns best path """
lang = standardize_lang_tag(lang)

Expand All @@ -33,11 +36,12 @@ def get_language_dir(base_path, lang="en-US"):
# 1- 3 -> These codes indicate a minor regional difference.
# 4 - 10 -> These codes indicate a significant but unproblematic regional difference.
if score < 10:
candidates.append((f, score))

candidates.append((f"{base_path}/{f}", score))
if not candidates:
return None
# sort by distance to target lang code
candidates = sorted(candidates, key=lambda k: k[1])
return candidates[0]
return candidates[0][0]


def translate_word(name, lang='en-US'):
Expand Down
4 changes: 2 additions & 2 deletions ovos_utils/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 3
VERSION_BUILD = 4
VERSION_ALPHA = 0
VERSION_BUILD = 5
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit 0978d47

Please sign in to comment.