mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
Merge pull request #2 from Nezumi-2711/i18n/vietnamese-domain-exceptions
feat(i18n): localize domain exceptions to Vietnamese
This commit is contained in:
+45
-23
@@ -30,31 +30,34 @@ class AnalysisException(DomainException):
|
|||||||
class InsufficientDataException(AnalysisException):
|
class InsufficientDataException(AnalysisException):
|
||||||
"""当数据不足以进行分析时抛出。"""
|
"""当数据不足以进行分析时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "数据不足,无法进行分析"):
|
def __init__(self, message: str = "Không đủ dữ liệu để phân tích"):
|
||||||
super().__init__(message, "INSUFFICIENT_DATA")
|
super().__init__(message, "INSUFFICIENT_DATA")
|
||||||
|
|
||||||
|
|
||||||
class AnalysisTimeoutException(AnalysisException):
|
class AnalysisTimeoutException(AnalysisException):
|
||||||
"""当分析超时时抛出。"""
|
"""当分析超时时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "分析超时"):
|
def __init__(self, message: str = "Phân tích bị timeout"):
|
||||||
super().__init__(message, "ANALYSIS_TIMEOUT")
|
super().__init__(message, "ANALYSIS_TIMEOUT")
|
||||||
|
|
||||||
|
|
||||||
class LLMException(AnalysisException):
|
class LLMException(AnalysisException):
|
||||||
"""当 LLM API 调用失败时抛出。"""
|
"""当 LLM API 调用失败时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "LLM API 调用失败", provider: str = ""):
|
def __init__(self, message: str = "Gọi API LLM thất bại", provider: str = ""):
|
||||||
self.provider = provider
|
self.provider = provider
|
||||||
super().__init__(
|
super().__init__(
|
||||||
f"{message} (提供商: {provider})" if provider else message, "LLM_ERROR"
|
f"{message} (nhà cung cấp: {provider})" if provider else message,
|
||||||
|
"LLM_ERROR",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class LLMRateLimitException(LLMException):
|
class LLMRateLimitException(LLMException):
|
||||||
"""当 LLM API 速率限制超出时抛出。"""
|
"""当 LLM API 速率限制超出时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "LLM 速率限制超出", provider: str = ""):
|
def __init__(
|
||||||
|
self, message: str = "Vượt quá giới hạn tốc độ LLM", provider: str = ""
|
||||||
|
):
|
||||||
super().__init__(message, provider)
|
super().__init__(message, provider)
|
||||||
self.code = "LLM_RATE_LIMIT"
|
self.code = "LLM_RATE_LIMIT"
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ class LLMRateLimitException(LLMException):
|
|||||||
class LLMQuotaExceededException(LLMException):
|
class LLMQuotaExceededException(LLMException):
|
||||||
"""当 LLM API 配额超出时抛出。"""
|
"""当 LLM API 配额超出时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "LLM 配额超出", provider: str = ""):
|
def __init__(self, message: str = "Vượt quá hạn ngạch LLM", provider: str = ""):
|
||||||
super().__init__(message, provider)
|
super().__init__(message, provider)
|
||||||
self.code = "LLM_QUOTA_EXCEEDED"
|
self.code = "LLM_QUOTA_EXCEEDED"
|
||||||
|
|
||||||
@@ -85,21 +88,23 @@ class PlatformNotSupportedException(PlatformException):
|
|||||||
|
|
||||||
def __init__(self, platform: str):
|
def __init__(self, platform: str):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
f"平台 '{platform}' 不被支持", platform, "PLATFORM_NOT_SUPPORTED"
|
f"Nền tảng '{platform}' không được hỗ trợ",
|
||||||
|
platform,
|
||||||
|
"PLATFORM_NOT_SUPPORTED",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PlatformConnectionException(PlatformException):
|
class PlatformConnectionException(PlatformException):
|
||||||
"""当连接平台失败时抛出。"""
|
"""当连接平台失败时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "连接平台失败", platform: str = ""):
|
def __init__(self, message: str = "Kết nối nền tảng thất bại", platform: str = ""):
|
||||||
super().__init__(message, platform, "PLATFORM_CONNECTION_ERROR")
|
super().__init__(message, platform, "PLATFORM_CONNECTION_ERROR")
|
||||||
|
|
||||||
|
|
||||||
class PlatformAPIException(PlatformException):
|
class PlatformAPIException(PlatformException):
|
||||||
"""当平台 API 调用失败时抛出。"""
|
"""当平台 API 调用失败时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "平台 API 调用失败", platform: str = ""):
|
def __init__(self, message: str = "Gọi API nền tảng thất bại", platform: str = ""):
|
||||||
super().__init__(message, platform, "PLATFORM_API_ERROR")
|
super().__init__(message, platform, "PLATFORM_API_ERROR")
|
||||||
|
|
||||||
|
|
||||||
@@ -107,11 +112,14 @@ class MessageFetchException(PlatformException):
|
|||||||
"""当获取消息失败时抛出。"""
|
"""当获取消息失败时抛出。"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, message: str = "获取消息失败", platform: str = "", group_id: str = ""
|
self,
|
||||||
|
message: str = "Lấy tin nhắn thất bại",
|
||||||
|
platform: str = "",
|
||||||
|
group_id: str = "",
|
||||||
):
|
):
|
||||||
self.group_id = group_id
|
self.group_id = group_id
|
||||||
super().__init__(
|
super().__init__(
|
||||||
f"{message} (群组: {group_id})" if group_id else message,
|
f"{message} (nhóm: {group_id})" if group_id else message,
|
||||||
platform,
|
platform,
|
||||||
"MESSAGE_FETCH_ERROR",
|
"MESSAGE_FETCH_ERROR",
|
||||||
)
|
)
|
||||||
@@ -121,11 +129,14 @@ class MessageSendException(PlatformException):
|
|||||||
"""当发送消息失败时抛出。"""
|
"""当发送消息失败时抛出。"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, message: str = "发送消息失败", platform: str = "", group_id: str = ""
|
self,
|
||||||
|
message: str = "Gửi tin nhắn thất bại",
|
||||||
|
platform: str = "",
|
||||||
|
group_id: str = "",
|
||||||
):
|
):
|
||||||
self.group_id = group_id
|
self.group_id = group_id
|
||||||
super().__init__(
|
super().__init__(
|
||||||
f"{message} (群组: {group_id})" if group_id else message,
|
f"{message} (nhóm: {group_id})" if group_id else message,
|
||||||
platform,
|
platform,
|
||||||
"MESSAGE_SEND_ERROR",
|
"MESSAGE_SEND_ERROR",
|
||||||
)
|
)
|
||||||
@@ -146,7 +157,7 @@ class ConfigurationException(DomainException):
|
|||||||
class InvalidConfigurationException(ConfigurationException):
|
class InvalidConfigurationException(ConfigurationException):
|
||||||
"""当配置无效时抛出。"""
|
"""当配置无效时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "无效的配置", key: str = ""):
|
def __init__(self, message: str = "Cấu hình không hợp lệ", key: str = ""):
|
||||||
self.key = key
|
self.key = key
|
||||||
super().__init__(f"{message}: {key}" if key else message, "INVALID_CONFIG")
|
super().__init__(f"{message}: {key}" if key else message, "INVALID_CONFIG")
|
||||||
|
|
||||||
@@ -156,7 +167,7 @@ class MissingConfigurationException(ConfigurationException):
|
|||||||
|
|
||||||
def __init__(self, key: str):
|
def __init__(self, key: str):
|
||||||
self.key = key
|
self.key = key
|
||||||
super().__init__(f"缺少必需配置: {key}", "MISSING_CONFIG")
|
super().__init__(f"Thiếu cấu hình bắt buộc: {key}", "MISSING_CONFIG")
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -175,12 +186,15 @@ class DataNotFoundException(RepositoryException):
|
|||||||
"""当请求的数据未找到时抛出。"""
|
"""当请求的数据未找到时抛出。"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, message: str = "数据未找到", entity_type: str = "", entity_id: str = ""
|
self,
|
||||||
|
message: str = "Không tìm thấy dữ liệu",
|
||||||
|
entity_type: str = "",
|
||||||
|
entity_id: str = "",
|
||||||
):
|
):
|
||||||
self.entity_type = entity_type
|
self.entity_type = entity_type
|
||||||
self.entity_id = entity_id
|
self.entity_id = entity_id
|
||||||
super().__init__(
|
super().__init__(
|
||||||
f"{entity_type} 未找到: {entity_id}" if entity_type else message,
|
f"Không tìm thấy {entity_type}: {entity_id}" if entity_type else message,
|
||||||
"DATA_NOT_FOUND",
|
"DATA_NOT_FOUND",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -188,7 +202,7 @@ class DataNotFoundException(RepositoryException):
|
|||||||
class DataPersistenceException(RepositoryException):
|
class DataPersistenceException(RepositoryException):
|
||||||
"""当数据持久化失败时抛出。"""
|
"""当数据持久化失败时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "数据持久化失败"):
|
def __init__(self, message: str = "Lưu trữ dữ liệu thất bại"):
|
||||||
super().__init__(message, "DATA_PERSISTENCE_ERROR")
|
super().__init__(message, "DATA_PERSISTENCE_ERROR")
|
||||||
|
|
||||||
|
|
||||||
@@ -209,7 +223,9 @@ class TaskAlreadyScheduledException(SchedulingException):
|
|||||||
|
|
||||||
def __init__(self, task_id: str):
|
def __init__(self, task_id: str):
|
||||||
self.task_id = task_id
|
self.task_id = task_id
|
||||||
super().__init__(f"任务已调度: {task_id}", "TASK_ALREADY_SCHEDULED")
|
super().__init__(
|
||||||
|
f"Tác vụ đã được lên lịch: {task_id}", "TASK_ALREADY_SCHEDULED"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TaskNotFoundException(SchedulingException):
|
class TaskNotFoundException(SchedulingException):
|
||||||
@@ -217,7 +233,9 @@ class TaskNotFoundException(SchedulingException):
|
|||||||
|
|
||||||
def __init__(self, task_id: str):
|
def __init__(self, task_id: str):
|
||||||
self.task_id = task_id
|
self.task_id = task_id
|
||||||
super().__init__(f"未找到已调度的任务: {task_id}", "TASK_NOT_FOUND")
|
super().__init__(
|
||||||
|
f"Không tìm thấy tác vụ đã lên lịch: {task_id}", "TASK_NOT_FOUND"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -237,18 +255,22 @@ class InvalidGroupIdException(ValidationException):
|
|||||||
"""当群组 ID 无效时抛出。"""
|
"""当群组 ID 无效时抛出。"""
|
||||||
|
|
||||||
def __init__(self, group_id: str):
|
def __init__(self, group_id: str):
|
||||||
super().__init__(f"无效的群组 ID: {group_id}", "group_id", "INVALID_GROUP_ID")
|
super().__init__(
|
||||||
|
f"ID nhóm không hợp lệ: {group_id}", "group_id", "INVALID_GROUP_ID"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class InvalidUserIdException(ValidationException):
|
class InvalidUserIdException(ValidationException):
|
||||||
"""当用户 ID 无效时抛出。"""
|
"""当用户 ID 无效时抛出。"""
|
||||||
|
|
||||||
def __init__(self, user_id: str):
|
def __init__(self, user_id: str):
|
||||||
super().__init__(f"无效的用户 ID: {user_id}", "user_id", "INVALID_USER_ID")
|
super().__init__(
|
||||||
|
f"ID người dùng không hợp lệ: {user_id}", "user_id", "INVALID_USER_ID"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class InvalidMessageException(ValidationException):
|
class InvalidMessageException(ValidationException):
|
||||||
"""当消息格式无效时抛出。"""
|
"""当消息格式无效时抛出。"""
|
||||||
|
|
||||||
def __init__(self, message: str = "无效的消息格式"):
|
def __init__(self, message: str = "Định dạng tin nhắn không hợp lệ"):
|
||||||
super().__init__(message, "message", "INVALID_MESSAGE")
|
super().__init__(message, "message", "INVALID_MESSAGE")
|
||||||
|
|||||||
Reference in New Issue
Block a user