1
0
mirror of synced 2024-11-15 03:07:40 +01:00
Retrieval-based-Voice-Conve.../webui_locale.py
Ftps c8261b2ccc
Reformat and rewrite _get_name_params (#57)
* Reformat

* rewrite _get_name_params

* Add workflow for automatic formatting

* Revert "Add workflow for automatic formatting"

This reverts commit 9111c5dbc1.

* revert Retrieval_based_Voice_Conversion_WebUI.ipynb

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2023-04-15 11:44:24 +00:00

23 lines
594 B
Python

import locale
import json
def load_language_list(language):
with open(f"./locale/{language}.json", "r", encoding="utf-8") as f:
language_list = json.load(f)
return language_list
class I18nAuto:
def __init__(self, language=None):
if language is None:
language = "auto"
if language == "auto":
language = locale.getdefaultlocale()[0]
self.language = language
print("Use Language:", language)
self.language_map = load_language_list(language)
def __call__(self, key):
return self.language_map[key]