Skip to content

Commit 22dc17b

Browse files
committed
feat(System): Language switch, supports Traditional Chinese.
1 parent 7290e74 commit 22dc17b

File tree

4 files changed

+203
-4
lines changed

4 files changed

+203
-4
lines changed

backend/apps/chat/task/llm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,8 @@ def get_lang_name(lang: str):
18321832
if not lang:
18331833
return '简体中文'
18341834
normalized = lang.lower()
1835+
if normalized.startswith('zh-tw'):
1836+
return '繁体中文'
18351837
if normalized.startswith('en'):
18361838
return '英文'
18371839
if normalized.startswith('ko'):

backend/apps/system/api/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def batch_del(session: SessionDep, id_list: list[int]):
273273
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="current_user.id")
274274
async def langChange(session: SessionDep, current_user: CurrentUser, trans: Trans, language: UserLanguage):
275275
lang = language.language
276-
if lang not in ["zh-CN", "en", "ko-KR"]:
276+
if lang not in ["zh-CN", "zh-TW", "en", "ko-KR"]:
277277
raise Exception(trans('i18n_user.language_not_support', key = lang))
278278
db_user: UserModel = get_db_user(session=session, user_id=current_user.id)
279279
db_user.language = lang

backend/apps/system/schemas/system_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BaseUser(BaseModel):
3232

3333

3434
class BaseUserDTO(BaseUser, BaseCreatorDTO):
35-
language: str = Field(pattern=r"^(zh-CN|en|ko-KR)$", default="zh-CN", description="用户语言")
35+
language: str = Field(pattern=r"^(zh-CN|zh-TW|en|ko-KR)$", default="zh-CN", description="用户语言")
3636
password: str
3737
status: int = 1
3838
origin: int = 0
@@ -47,8 +47,8 @@ def to_dict(self):
4747

4848
@field_validator("language")
4949
def validate_language(cls, lang: str) -> str:
50-
if not re.fullmatch(r"^(zh-CN|en|ko-KR)$", lang):
51-
raise ValueError("Language must be 'zh-CN', 'en', or 'ko-KR'")
50+
if not re.fullmatch(r"^(zh-CN|zh-TW|en|ko-KR)$", lang):
51+
raise ValueError("Language must be 'zh-CN', 'zh-TW', 'en', or 'ko-KR'")
5252
return lang
5353

5454

backend/locales/zh-TW.json

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
{
2+
"i18n_default_workspace": "默認工作空間",
3+
"i18n_ds_name_exist": "名稱已存在",
4+
"i18n_concat_admin": "請聯繫管理員!",
5+
"i18n_exist": "{msg}已存在!",
6+
"i18n_name": "名稱",
7+
"i18n_not_exist": "{msg}不存在!",
8+
"i18n_error": "{key}錯誤!",
9+
"i18n_miss_args": "缺失{key}參數!",
10+
"i18n_format_invalid": "{key}格式不正確!",
11+
"i18n_login": {
12+
"account_pwd_error": "帳號或密碼錯誤!",
13+
"no_associated_ws": "沒有關聯的工作空間,{msg}",
14+
"user_disable": "帳號已禁用,{msg}",
15+
"origin_error": "登入方式錯誤",
16+
"prohibit_auto_create": "禁止自動建立用戶,請先同步用戶",
17+
"no_platform_user": "帳號不存在,請先同步用戶"
18+
},
19+
"i18n_user": {
20+
"account": "帳號",
21+
"email": "郵箱",
22+
"password": "密碼",
23+
"language_not_support": "系統不支援[{key}]語言!",
24+
"ws_miss": "當前用戶不在工作空間[{ws}]中!",
25+
"name": "姓名",
26+
"status": "用戶狀態",
27+
"origin": "用戶來源",
28+
"workspace": "工作空間",
29+
"role": "角色",
30+
"platform_user_id": "外部用戶唯一標識",
31+
"administrator": "管理員",
32+
"ordinary_member": "普通成員",
33+
"status_enabled": "已啟用",
34+
"status_disabled": "已禁用",
35+
"local_creation": "本地建立"
36+
},
37+
"i18n_ws": {
38+
"title": "工作空間"
39+
},
40+
"i18n_permission": {
41+
"only_admin": "僅支援管理員調用!",
42+
"no_permission": "無權調用{url}{msg}",
43+
"authenticate_invalid": "認證無效【{msg}】",
44+
"token_expired": "Token 已過期",
45+
"only_ws_admin": "僅支援工作空間管理員調用!",
46+
"permission_resource_limit": "沒有操作權限或資源不存在!"
47+
},
48+
"i18n_llm": {
49+
"validate_error": "校驗失敗[{msg}]",
50+
"delete_default_error": "無法刪除默認模型[{key}]!",
51+
"miss_default": "尚未配置默認大語言模型"
52+
},
53+
"i18n_ds_invalid": "數據源連接無效",
54+
"i18n_embedded": {
55+
"invalid_origin": "網域校驗失敗【{origin}】"
56+
},
57+
"i18n_chat": {
58+
"record_id_in_mcp": "響應ID: "
59+
},
60+
"i18n_terminology": {
61+
"terminology_not_exists": "該術語不存在",
62+
"datasource_cannot_be_none": "數據源不能為空",
63+
"cannot_be_repeated": "術語名稱,同義詞不能重複",
64+
"exists_in_db": "術語名稱,同義詞已存在",
65+
"term_name": "術語名稱",
66+
"term_description": "術語描述",
67+
"effective_data_sources": "生效數據源",
68+
"all_data_sources": "所有數據源",
69+
"synonyms": "同義詞",
70+
"term_name_template": "術語名稱(必填)",
71+
"term_description_template": "術語描述(必填)",
72+
"effective_data_sources_template": "生效數據源(支援多個,用\",\"分割)",
73+
"all_data_sources_template": "所有數據源(Y:應用到全部數據源,N:應用到指定數據源)",
74+
"synonyms_template": "同義詞(支援多個,用\",\"分割)",
75+
"term_name_template_example_1": "術語1",
76+
"term_description_template_example_1": "術語1描述",
77+
"effective_data_sources_template_example_1": "生效數據源1, 生效數據源2",
78+
"synonyms_template_example_1": "同義詞1, 同義詞2",
79+
"term_name_template_example_2": "術語2",
80+
"term_description_template_example_2": "術語2描述",
81+
"synonyms_template_example_2": "同義詞3",
82+
"word_cannot_be_empty": "術語名稱不能為空",
83+
"description_cannot_be_empty": "術語描述不能為空",
84+
"datasource_not_found": "找不到數據源"
85+
},
86+
"i18n_data_training": {
87+
"datasource_list_is_not_found": "數據源列表未找到",
88+
"datasource_id_not_found": "數據源ID: {key} 未找到",
89+
"datasource_cannot_be_none": "數據源不能為空",
90+
"datasource_assistant_cannot_be_none": "數據源或高級應用不能都為空",
91+
"data_training_not_exists": "該範例不存在",
92+
"exists_in_db": "該問題已存在",
93+
"data_training": "SQL 範例庫",
94+
"problem_description": "問題描述",
95+
"sample_sql": "範例 SQL",
96+
"effective_data_sources": "生效數據源",
97+
"advanced_application": "高級應用",
98+
"problem_description_template": "問題描述(必填)",
99+
"sample_sql_template": "範例 SQL(必填)",
100+
"effective_data_sources_template": "生效數據源",
101+
"advanced_application_template": "高級應用",
102+
"problem_description_template_example": "查詢TEST表內所有ID",
103+
"effective_data_sources_template_example": "生效數據源1",
104+
"advanced_application_template_example": "生效高級應用名稱",
105+
"error_info": "錯誤訊息",
106+
"question_cannot_be_empty": "問題不能為空",
107+
"description_cannot_be_empty": "範例 SQL 不能為空",
108+
"datasource_not_found": "找不到數據源",
109+
"advanced_application_not_found": "找不到高級應用"
110+
},
111+
"i18n_custom_prompt": {
112+
"exists_in_db": "模版名稱已存在",
113+
"not_exists": "該模版不存在",
114+
"prompt_word_name": "提示詞名稱",
115+
"prompt_word_content": "提示詞內容",
116+
"effective_data_sources": "生效數據源",
117+
"all_data_sources": "所有數據源",
118+
"prompt_word_name_template": "提示詞名稱(必填)",
119+
"prompt_word_content_template": "提示詞內容(必填)",
120+
"effective_data_sources_template": "生效數據源(支援多個,用\",\"分割)",
121+
"all_data_sources_template": "所有數據源(Y:應用到全部數據源,N:應用到指定數據源)",
122+
"prompt_word_name_template_example1": "提示詞1",
123+
"prompt_word_content_template_example1": "詳細描述你的提示詞",
124+
"effective_data_sources_template_example1": "生效數據源1, 生效數據源2",
125+
"prompt_word_name_template_example2": "提示詞2",
126+
"prompt_word_content_template_example2": "詳細描述你的提示詞",
127+
"name_cannot_be_empty": "名稱不能為空",
128+
"prompt_cannot_be_empty": "提示詞內容不能為空",
129+
"type_cannot_be_empty": "類型不能為空",
130+
"datasource_not_found": "找不到數據源",
131+
"datasource_cannot_be_none": "數據源不能為空"
132+
},
133+
"i18n_excel_export": {
134+
"data_is_empty": "表單數據為空,無法導出數據"
135+
},
136+
"i18n_excel_import": {
137+
"col_num_not_match": "EXCEL列數量不匹配"
138+
},
139+
"i18n_authentication": {
140+
"record_not_exist": "{msg} 記錄不存在,請先儲存!"
141+
},
142+
"i18n_audit": {
143+
"success": "成功",
144+
"failed": "失敗",
145+
"system_log": "操作日誌",
146+
"operation_type_name": "操作類型",
147+
"operation_detail_info": "操作詳情",
148+
"user_name": "操作用戶",
149+
"oid_name": "工作空間",
150+
"operation_status_name": "操作狀態",
151+
"error_message": "錯誤訊息",
152+
"ip_address": "IP 地址",
153+
"create_time": "操作時間",
154+
"chat": "智能問數",
155+
"datasource": "數據源",
156+
"dashboard": "儀表板",
157+
"member": "成員",
158+
"permission": "權限",
159+
"terminology": "術語",
160+
"data_training": "SQL 範例庫",
161+
"prompt_words": "提示詞",
162+
"user": "用戶",
163+
"workspace": "工作空間",
164+
"ai_model": "AI 模型",
165+
"application": "應用",
166+
"theme": "外觀配置",
167+
"create": "新建",
168+
"delete": "刪除",
169+
"update": "更新",
170+
"edit": "編輯",
171+
"login": "登入",
172+
"export": "匯出",
173+
"import": "匯入",
174+
"add": "新增",
175+
"create_or_update": "變更",
176+
"api_key": "API Key",
177+
"params_setting": "參數配置",
178+
"rules": "權限規則",
179+
"log_setting": "登入認證",
180+
"setting": "設定",
181+
"system_management": "系統管理",
182+
"opt_log": "操作日誌",
183+
"prediction": "數據預測",
184+
"analysis": "數據分析",
185+
"reset_pwd": "重置密碼",
186+
"update_pwd": "更新密碼",
187+
"update_status": "更新狀態",
188+
"update_table_relation": "變更表關係"
189+
},
190+
"i18n_table_not_exist": "當前表不存在",
191+
"i18n_variable": {
192+
"name_exist": "變數名稱已存在",
193+
"name": "姓名",
194+
"account": "帳號",
195+
"email": "郵箱"
196+
}
197+
}

0 commit comments

Comments
 (0)