中英文切换 初始化
This commit is contained in:
29
.workbuddy/update_request.py
Normal file
29
.workbuddy/update_request.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import re
|
||||
|
||||
with open('src/api/request.ts', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Add i18n import after existing imports
|
||||
content = content.replace(
|
||||
"import utils from '../lib/utils';",
|
||||
"import utils from '../lib/utils';\nimport i18n from '../i18n';"
|
||||
)
|
||||
|
||||
# Replace Chinese error messages
|
||||
content = content.replace(
|
||||
"message?.error('\u767b\u5f55\u5df2\u8fc7\u671f\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55')",
|
||||
"message?.error(i18n.t('api.loginExpired'))"
|
||||
)
|
||||
content = content.replace(
|
||||
"return Promise.reject(new Error('\u767b\u5f55\u5df2\u8fc7\u671f'))",
|
||||
"return Promise.reject(new Error(i18n.t('api.loginExpired')))"
|
||||
)
|
||||
content = content.replace(
|
||||
"message?.error('\u7f51\u7edc\u5f02\u5e38\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5')",
|
||||
"message?.error(i18n.t('api.networkError'))"
|
||||
)
|
||||
|
||||
with open('src/api/request.ts', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print("request.ts updated successfully")
|
||||
Reference in New Issue
Block a user