mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Handle base language (English) better
- Don't log an error about a missing language file at startup. - Don't append to untranslated.txt for strings that don't need translation because they're already in the target language. I could use an early return for this too, but it's not important.
This commit is contained in:
parent
7b0eaff108
commit
adcaed47cd
@ -3,7 +3,8 @@ import json
|
||||
import re
|
||||
|
||||
translations = {}
|
||||
current_language = "en"
|
||||
base_language = "en"
|
||||
current_language = base_language
|
||||
|
||||
def get_direction() -> str:
|
||||
"""Get the text direction for the current language."""
|
||||
@ -15,6 +16,8 @@ def load_language(language_code: str):
|
||||
"""Load a language from the translations directory."""
|
||||
global translations
|
||||
translations = {}
|
||||
if language_code == base_language:
|
||||
return
|
||||
try:
|
||||
with open(f"localization/{language_code}/localizations.js", "r") as f:
|
||||
# find the JSON object
|
||||
@ -67,7 +70,7 @@ def get(base_language_str: str, *interpolations: str) -> str:
|
||||
if base_language_str[-3:] == "...":
|
||||
return find_localization(base_language_str[:-3]) + "..."
|
||||
|
||||
if base_language_str not in untranslated:
|
||||
if base_language_str not in untranslated and current_language != base_language:
|
||||
untranslated.add(base_language_str)
|
||||
# append to untranslated strings file
|
||||
with open("localization/untranslated.txt", "a") as f:
|
||||
|
Loading…
Reference in New Issue
Block a user