Skip to content

Commit

Permalink
enhance default translation log
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Jan 17, 2024
1 parent cfc03b8 commit 2887a7b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,21 @@ class ChainlitConfig:

def load_translation(self, language: str):
translation = {}
default_language = "en-US"

translation_lib_file_path = os.path.join(
config_translation_dir, f"{language}.json"
)
default_translation_lib_file_path = os.path.join(
config_translation_dir, f"en-US.json"
config_translation_dir, f"{default_language}.json"
)

if os.path.exists(translation_lib_file_path):
with open(translation_lib_file_path, "r", encoding="utf-8") as f:
translation = json.load(f)
elif os.path.exists(default_translation_lib_file_path):
logger.warning(
f"Translation file for {language} not found. Using default translation."
f"Translation file for {language} not found. Using default translation {default_language}."
)
with open(default_translation_lib_file_path, "r", encoding="utf-8") as f:
translation = json.load(f)
Expand Down

0 comments on commit 2887a7b

Please sign in to comment.