Add a more helpful error for a messed up default translation
This commit is contained in:
1 parent
22f442fcad
commit
8f0f94c32b
1 file changed
+7
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
from collections import abc
|
from collections import abc
|
||||||
from typing import Any, TypedDict, TYPE_CHECKING
|
from typing import Any, TypedDict, TYPE_CHECKING
|
||||||
|
|
||||||
|
from exceptions import MinerException
|
||||||
from utils import json_load, json_save
|
from utils import json_load, json_save
|
||||||
from constants import IS_PACKAGED, LANG_PATH, DEFAULT_LANG
|
from constants import IS_PACKAGED, LANG_PATH, DEFAULT_LANG
|
||||||
|
|
||||||
@@ -431,8 +432,14 @@ class Translator:
|
|||||||
if not path:
|
if not path:
|
||||||
raise ValueError("Language path expected")
|
raise ValueError("Language path expected")
|
||||||
v: Any = self._translation
|
v: Any = self._translation
|
||||||
|
try:
|
||||||
for key in path:
|
for key in path:
|
||||||
v = v[key]
|
v = v[key]
|
||||||
|
except KeyError:
|
||||||
|
# this can only really happen for the default translation
|
||||||
|
raise MinerException(
|
||||||
|
f"{self.current} translation is missing the '{' -> '.join(path)}' translation key"
|
||||||
|
)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user