Added better error output (based on #963)
This commit is contained in:
parent
5990491292
commit
49a93480a8
|
|
@ -42,5 +42,10 @@ class UserError(BaseException):
|
||||||
class ServiceException(BaseException):
|
class ServiceException(BaseException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PackageError(BaseException):
|
class PackageError(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TranslationError(BaseException):
|
||||||
pass
|
pass
|
||||||
|
|
@ -6,7 +6,7 @@ import gettext
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
|
from .exceptions import TranslationError
|
||||||
|
|
||||||
class Languages:
|
class Languages:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
@ -60,7 +60,10 @@ class Translation:
|
||||||
self._languages = {}
|
self._languages = {}
|
||||||
|
|
||||||
for name in self.get_all_names():
|
for name in self.get_all_names():
|
||||||
self._languages[name] = gettext.translation('base', localedir=locales_dir, languages=[name])
|
try:
|
||||||
|
self._languages[name] = gettext.translation('base', localedir=locales_dir, languages=[name])
|
||||||
|
except FileNotFoundError as error:
|
||||||
|
raise TranslationError(f"Could not locate language file for '{name}': {error}")
|
||||||
|
|
||||||
def activate(self, name):
|
def activate(self, name):
|
||||||
if language := self._languages.get(name, None):
|
if language := self._languages.get(name, None):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue