添加多语言(i18n)支持 - #3206
Conversation
Maxcj
commented
Jun 20, 2026
- 根据 Django 文档以及另外一个 PR(3115) 完成
- 范围包含登录、前台、后台页面
- 目前已内置简体中文(zh_Hans), English(en)两种语言
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50f8222b58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04f6354eb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| QueryLog(id=query_log_id, favorite=star, alias=alias).save( | ||
| update_fields=["favorite", "alias"] | ||
| ) |
There was a problem hiding this comment.
Keep favorite updates scoped to the owner
For non-auditor users, the list endpoint still filters QueryLog by username, but this direct model save updates whichever primary key is posted. Any user with sql.menu_sqlquery can guess another log id and change its favorite flag/alias; use the existing QueryLog.objects.filter(id=...).filter(username=...) path (or the service) before updating.
Useful? React with 👍 / 👎.
| } | ||
| // 执行结果页默认不新增 | ||
| else if (active_li_title.match(/^执行结果\d$/)) { | ||
| else if (active_li_title.match(/^Execution Result\d$/)) { |
There was a problem hiding this comment.
Match localized result tab titles
In zh-hans the result tab is created with gettext("Execution Result"), which becomes 执行结果1, so this English-only regex no longer recognizes the active result tab. Subsequent queries while a result tab is selected always create another tab instead of updating/reusing the current one, and the SQL cache update above has the same mismatch; compare against an unlocalized tab id or a translated prefix instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a82f36102
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| sql_content = request.POST.get("sql_content") | ||
| db_name = request.POST.get("db_name") | ||
| tb_name = request.POST.get("tb_name") | ||
| limit_num = int(request.POST.get("limit_num", 0)) |
There was a problem hiding this comment.
Validate nonnumeric query limits before casting
When a client posts an empty or nonnumeric limit_num value, this cast runs before the new JSON error handling and raises ValueError, so /query/ returns a 500 instead of the structured error that execute_sql_query() previously returned for invalid limits. Keep the conversion inside a try/except and reject bad limits with a JSON response.
Useful? React with 👍 / 👎.
| operation_type=5, | ||
| operation_type_desc="执行工单", | ||
| operation_info="工单执行排队中", | ||
| operation_type_desc=_("Execute workflow"), # 执行工单 |
There was a problem hiding this comment.
Keep persisted log descriptions within field length
When the active language is English, this translated value is Execute workflow (and the manual/scheduled descriptions below are also longer), but WorkflowLog.operation_type_desc is max_length=10. Saving these audit log entries in MySQL strict mode will fail, or truncate in lax configurations, when executing or scheduling workflows, so keep the stored code/short text unlocalized and localize only for display.
Useful? React with 👍 / 👎.
| $("#end_file").empty(); | ||
| for (var i = 0; i < result.length; i++) { | ||
| var name = "<option value=\"" + result[i]['Log_name'] + "\">" + result[i]['Log_name'] + ' Size:' + result[i]['File_size'] + "</option>"; | ||
| var name = "<option value=\"" + result[i]['Log_name'] + "\">" + result[i]['Log_name'] + ' ' + gettext('Size:') + result[i]['File_size'] + "</option>"; |
There was a problem hiding this comment.
Keep My2SQL size parsing independent of labels
When zh-hans is active, gettext('Size:') renders as 大小:, but the click handler below still derives the default end position with .split('Size:')[1]. That leaves end_pos unset when users click My2SQL without manually entering an end position, so the request omits -stop-pos and can parse a different binlog range than the selected file size intended; store the size in the option value/data attribute instead of parsing localized text.
Useful? React with 👍 / 👎.