mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-04-18 13:02:10 +00:00
ISO lang code support for --load-only
Some checks are pending
Build and Publish Docker Image / main (push) Waiting to run
Run tests / tests_python (3.9) (push) Waiting to run
Run tests / test_docker_build (push) Waiting to run
Run tests / tests_python (3.10) (push) Waiting to run
Run tests / tests_python (3.8) (push) Waiting to run
Some checks are pending
Build and Publish Docker Image / main (push) Waiting to run
Run tests / tests_python (3.9) (push) Waiting to run
Run tests / test_docker_build (push) Waiting to run
Run tests / tests_python (3.10) (push) Waiting to run
Run tests / tests_python (3.8) (push) Waiting to run
This commit is contained in:
parent
29c9f39e8f
commit
182f6063f0
2 changed files with 5 additions and 0 deletions
|
@ -27,6 +27,8 @@ def check_and_install_models(force=False, load_only_lang_codes=None,update=False
|
|||
print("Found %s models" % len(available_packages))
|
||||
if load_only_lang_codes is not None:
|
||||
# load_only_lang_codes: List[str] (codes)
|
||||
load_only_lang_codes = libretranslate.language.iso2model(load_only_lang_codes)
|
||||
|
||||
# Ensure the user does not use any unavailable language code.
|
||||
unavailable_lang_codes = set(load_only_lang_codes)
|
||||
for pack in available_packages:
|
||||
|
|
|
@ -14,6 +14,9 @@ aliases = {
|
|||
rev_aliases = {v.lower(): k for k, v in aliases.items()}
|
||||
|
||||
def iso2model(lang):
|
||||
if isinstance(lang, list):
|
||||
return [iso2model(l) for l in lang]
|
||||
|
||||
if not isinstance(lang, str):
|
||||
return lang
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue