2022-06-29 13:45:25 +08:00
|
|
|
# -------------------------------
|
|
|
|
# Difficult Rocket
|
2023-01-20 14:08:12 +08:00
|
|
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
2022-06-29 13:45:25 +08:00
|
|
|
# All rights reserved
|
|
|
|
# -------------------------------
|
|
|
|
|
2023-03-02 13:15:29 +08:00
|
|
|
from Difficult_Rocket.exception import BaseError
|
2022-06-29 13:45:25 +08:00
|
|
|
|
|
|
|
__all__ = ['LanguageNotFound',
|
|
|
|
'TranslateError',
|
|
|
|
'TranslateKeyNotFound',
|
|
|
|
'TranslateFileNotFound']
|
|
|
|
|
|
|
|
|
|
|
|
class LanguageNotFound(BaseError):
|
|
|
|
"""语言文件缺失"""
|
|
|
|
|
|
|
|
|
|
|
|
class TranslateError(BaseError):
|
|
|
|
"""翻译相关问题"""
|
|
|
|
|
|
|
|
|
|
|
|
class TranslateKeyNotFound(TranslateError):
|
|
|
|
"""语言文件某项缺失"""
|
2023-01-16 18:34:17 +08:00
|
|
|
def __init__(self, value: dict = None, item_names: list = None):
|
2022-11-26 21:48:55 +08:00
|
|
|
self.item_names: list = item_names
|
2023-01-16 18:34:17 +08:00
|
|
|
self.value: dict = value
|
2022-11-26 21:48:55 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
2023-01-16 18:34:17 +08:00
|
|
|
return f"{self.__class__.__name__}: Can't get item {'. '.join(self.item_names)} from: {self.value}"
|
2022-06-29 13:45:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
class TranslateFileNotFound(TranslateError):
|
|
|
|
"""翻译文件缺失"""
|
2022-11-26 21:48:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|