diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-05-15 11:52:20 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | 76e709193614b3668d3c31a078e667473af20369 (patch) | |
| tree | 66f0e6caf03e19b5034c687e3b4c3cbd904be03a /wrappers/python/eduvpn_common/main.py | |
| parent | c1847c9cf76cb17e5b027ac4c0aea99d15852d45 (diff) | |
Initial i18n implementation
Diffstat (limited to 'wrappers/python/eduvpn_common/main.py')
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index f3639e0..335b78c 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -1,4 +1,5 @@ import ctypes +import json from enum import IntEnum from typing import Any, Callable, Iterator, Optional @@ -17,14 +18,19 @@ from eduvpn_common.state import State class WrappedError(Exception): - pass + def __init__(self, translations, language, misc): + self.translations = translations + self.language = language + self.misc = misc + def __str__(self) -> str: + print(self.translations) + return self.translations[self.language] -def forwardError(error: bytes | str): - # TODO: HACK, remove this - if isinstance(error, str): - raise WrappedError(error) - raise WrappedError(error.decode("utf-8")) + +def forwardError(error: str): + d = json.loads(error) + raise WrappedError(d["message"], "en", d["misc"]) class ServerType(IntEnum): |
