Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: extract local message files for sql review (#1801)
ecmadaoc45018fa0442
diff --git a/frontend/src/components/DatabaseSchemaReview/SchemaReviewPreview.vue b/frontend/src/components/DatabaseSchemaReview/SchemaReviewPreview.vueindex 4647892f12..43ade5102a 100644--- a/frontend/src/components/DatabaseSchemaReview/SchemaReviewPreview.vue+++ b/frontend/src/components/DatabaseSchemaReview/SchemaReviewPreview.vue@@ -28,7 +28,7 @@:id="category.id.replace(/\./g, '-')"class="text-left text-2xl text-indigo-600 font-semibold hover:underline">- {{ $t(`schema-review-policy.category.${category.id.toLowerCase()}`) }}+ {{ $t(`sql-review.category.${category.id.toLowerCase()}`) }}</a><div v-for="rule in category.ruleList" :key="rule.type" class="py-4"><div class="sm:flex sm:items-center sm:space-x-4">@@ -42,7 +42,7 @@<div class="mt-3 flex items-center space-x-2 sm:mt-0"><SchemaRuleLevelBadge :level="rule.level" /><BBBadge- :text="$t(`engine.${rule.engine.toLowerCase()}`)"+ :text="$t(`sql-review.engine.${rule.engine.toLowerCase()}`)":can-remove="false"/></div>@@ -58,7 +58,7 @@>{{$t(- `schema-review-policy.rule.${getRuleLocalizationKey(+ `sql-review.rule.${getRuleLocalizationKey(rule.type)}.component.${component.key}.title`)diff --git a/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewSidebar.vue b/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewSidebar.vueindex fd34974079..78f4f24ace 100644--- a/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewSidebar.vue+++ b/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewSidebar.vue@@ -6,7 +6,7 @@</h1><fieldset v-for="(category, index) in categoryList" :key="index"><div class="block text-sm font-medium text-gray-900">- {{ $t(`schema-review-policy.category.${category.id.toLowerCase()}`) }}+ {{ $t(`sql-review.category.${category.id.toLowerCase()}`) }}</div><divv-for="(rule, ruleIndex) in category.ruleList"diff --git a/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewTemplates.vue b/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewTemplates.vueindex f8e9410331..eeefc3efe6 100644--- a/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewTemplates.vue+++ b/frontend/src/components/DatabaseSchemaReview/components/SchemaReviewTemplates.vue@@ -20,13 +20,7 @@><img class="h-24" :src="getTemplateImage(template.id)" alt="" /><span class="text-sm lg:text-base mt-4">- {{- $t(- `schema-review-policy.template.${template.id- .split(".")- .join("-")}`- )- }}+ {{ $t(`sql-review.template.${template.id.split(".").join("-")}`) }}</span><heroicons-solid:check-circlev-if="index == selectedTemplateIndex"diff --git a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vue b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vueindex 2e9e5f6bbd..7302099178 100644--- a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vue+++ b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleConfig.vue@@ -15,7 +15,7 @@{{ getRuleLocalization(selectedRule.type).title }}</h1><BBBadge- :text="$t(`engine.${selectedRule.engine.toLowerCase()}`)"+ :text="$t(`sql-review.engine.${selectedRule.engine.toLowerCase()}`)":can-remove="false"/><SchemaRuleLevelBadge :level="selectedRule.level" />@@ -27,7 +27,7 @@</div><div v-if="active" class="px-10 py-5 text-sm"><div class="mb-7">- <p class="mb-3">{{ $t("schema-review-policy.error-level.name") }}</p>+ <p class="mb-3">{{ $t("sql-review.level.name") }}</p><div class="flex gap-x-3"><divv-for="(level, index) in LEVEL_LIST"@@ -46,9 +46,7 @@:for="`level-${level}`"class="ml-2 items-center text-sm text-gray-600">- {{- $t(`schema-review-policy.error-level.${level.toLowerCase()}`)- }}+ {{ $t(`sql-review.level.${level.toLowerCase()}`) }}</label></div></div>@@ -61,7 +59,7 @@<p class="mb-3">{{$t(- `schema-review-policy.rule.${getRuleLocalizationKey(+ `sql-review.rule.${getRuleLocalizationKey(selectedRule.type)}.component.${config.key}.title`)@@ -102,7 +100,7 @@config.payload.templateList.map((id) => ({id,description: $t(- `schema-review-policy.rule.${getRuleLocalizationKey(+ `sql-review.rule.${getRuleLocalizationKey(selectedRule.type)}.component.${config.key}.template.${id}`),diff --git a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vue b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vueindex 3aecc054f2..7528f37d25 100644--- a/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vue+++ b/frontend/src/components/DatabaseSchemaReview/components/SchemaRuleLevelBadge.vue@@ -1,6 +1,6 @@<template><BBBadge- :text="$t(`schema-review-policy.error-level.${level.toLowerCase()}`)"+ :text="$t(`sql-review.level.${level.toLowerCase()}`)":can-remove="false":style="style"/>diff --git a/frontend/src/components/Issue/TaskCheckRunPanel.vue b/frontend/src/components/Issue/TaskCheckRunPanel.vueindex 7efa358723..e803e6870e 100644--- a/frontend/src/components/Issue/TaskCheckRunPanel.vue+++ b/frontend/src/components/Issue/TaskCheckRunPanel.vue@@ -157,7 +157,7 @@ export default defineComponent({if (rule) {const ruleLocalization = getRuleLocalization(rule.type);title = `[${t(- `schema-review-policy.category.${rule.category.toLowerCase()}`+ `sql-review.category.${rule.category.toLowerCase()}`)}] ${ruleLocalization.title}`;} else {title = checkResult.title;diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 528ff6145e..151b63d510 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1438,123 +1438,7 @@"disable": "Disable","enable": "Enable","delete": "Delete schema review policy",- "category": {- "engine": "Engine",- "naming": "Naming",- "statement": "Statement",- "table": "Table",- "column": "Column",- "schema": "Schema"- },- "template": {- "mysql-prod": "Production Environment Template",- "mysql-dev": "Development Environment Template"- },"input-then-press-enter": "Input the value then press enter to add",- "rule": {- "engine-mysql-use-innodb": {- "title": "Use Innodb",- "description": "Require InnoDB as the storage engine for MySQL."- },- "table-require-pk": {- "title": "Require primary key",- "description": "Require the table to have a primary key."- },- "naming-table": {- "title": "Table naming check",- "description": "Enforce the table name format. Default snake_lower_case.",- "component": {- "name_format": {- "title": "Table name format (regex)"- }- }- },- "naming-column": {- "title": "Column naming check",- "description": "Enforce the column name format. Default snake_lower_case.",- "component": {- "name_format": {- "title": "Column name format (regex)"- }- }- },- "naming-index-uk": {- "title": "Unique key naming check",- "description": "Enforce the unique key name format. Default uk_<table_name>_<column_list>.",- "component": {- "name_format": {- "title": "Unique key name format",- "template": {- "table": "The table name",- "column_list": "Index column names, joined by _"- }- }- }- },- "naming-index-fk": {- "title": "Foreign key naming check",- "description": "Enforce the foreign key name format. Default fk_<referencing_table>_<referencing_column>_<referenced_table>_<referenced_column>.",- "component": {- "name_format": {- "title": "Foreign key name format",- "template": {- "referencing_table": "The referencing table name",- "referencing_column": "The referencing column name",- "referenced_table": "The referenced table name",- "referenced_column": "The referenced column name"- }- }- }- },- "naming-index-idx": {- "title": "Index naming check",- "description": "Enforce the index name format. Default idx_<table_name>_<column_list>.",- "component": {- "name_format": {- "title": "Index name format",- "template": {- "table": "The table name",- "column_list": "Index column names, joined by _"- }- }- }- },- "column-required": {- "title": "Required columns",- "description": "Enforce the required columns in each table.",- "component": {- "column_list": {- "title": "Required column names"- }- }- },- "column-no-null": {- "title": "Disallow NULL",- "description": "Columns cannot have NULL value."- },- "statement-select-no-select-all": {- "title": "Disallow \"SELECT *\"",- "description": "Disallow 'SELECT *' statement."- },- "statement-where-require": {- "title": "Require \"WHERE\"",- "description": "Require 'WHERE' clause."- },- "statement-where-no-leading-wildcard-like": {- "title": "Disallow leading wildcard like",- "description": "Disallow leading '%' in LIKE, e.g. LIKE foo = '%x' is not allowed."- },- "schema-backward-compatibility": {- "title": "Backward compatibility",- "description": "MySQL and TiDB support checking whether the schema change is backward compatible."- }- },- "error-level": {- "name": "Error Level",- "error": "Error",- "warning": "Warning",- "disabled": "Disabled"- },"create": {"breadcrumb": "Create schema review policy","basic-info": {diff --git a/frontend/src/locales/sql-review/en-US.json b/frontend/src/locales/sql-review/en-US.jsonnew file mode 100644index 0000000000..e0f194c5c4--- /dev/null+++ b/frontend/src/locales/sql-review/en-US.json@@ -0,0 +1,122 @@+{+ "engine": {+ "mysql": "MySQL",+ "common": "Common"+ },+ "category": {+ "engine": "Engine",+ "naming": "Naming",+ "statement": "Statement",+ "table": "Table",+ "column": "Column",+ "schema": "Schema"+ },+ "template": {+ "mysql-prod": "Production Environment Template",+ "mysql-dev": "Development Environment Template"+ },+ "rule": {+ "engine-mysql-use-innodb": {+ "title": "Use Innodb",+ "description": "Require InnoDB as the storage engine for MySQL."+ },+ "table-require-pk": {+ "title": "Require primary key",+ "description": "Require the table to have a primary key."+ },+ "naming-table": {+ "title": "Table naming check",+ "description": "Enforce the table name format. Default snake_lower_case.",+ "component": {+ "name_format": {+ "title": "Table name format (regex)"+ }+ }+ },+ "naming-column": {+ "title": "Column naming check",+ "description": "Enforce the column name format. Default snake_lower_case.",+ "component": {+ "name_format": {+ "title": "Column name format (regex)"+ }+ }+ },+ "naming-index-uk": {+ "title": "Unique key naming check",+ "description": "Enforce the unique key name format. Default uk_<table_name>_<column_list>.",+ "component": {+ "name_format": {+ "title": "Unique key name format",+ "template": {+ "table": "The table name",+ "column_list": "Index column names, joined by _"+ }+ }+ }+ },+ "naming-index-fk": {+ "title": "Foreign key naming check",+ "description": "Enforce the foreign key name format. Default fk_<referencing_table>_<referencing_column>_<referenced_table>_<referenced_column>.",+ "component": {+ "name_format": {+ "title": "Foreign key name format",+ "template": {+ "referencing_table": "The referencing table name",+ "referencing_column": "The referencing column name",+ "referenced_table": "The referenced table name",+ "referenced_column": "The referenced column name"+ }+ }+ }+ },+ "naming-index-idx": {+ "title": "Index naming check",+ "description": "Enforce the index name format. Default idx_<table_name>_<column_list>.",+ "component": {+ "name_format": {+ "title": "Index name format",+ "template": {+ "table": "The table name",+ "column_list": "Index column names, joined by _"+ }+ }+ }+ },+ "column-required": {+ "title": "Required columns",+ "description": "Enforce the required columns in each table.",+ "component": {+ "column_list": {+ "title": "Required column names"+ }+ }+ },+ "column-no-null": {+ "title": "Disallow NULL",+ "description": "Columns cannot have NULL value."+ },+ "statement-select-no-select-all": {+ "title": "Disallow \"SELECT *\"",+ "description": "Disallow 'SELECT *' statement."+ },+ "statement-where-require": {+ "title": "Require \"WHERE\"",+ "description": "Require 'WHERE' clause."+ },+ "statement-where-no-leading-wildcard-like": {+ "title": "Disallow leading wildcard like",+ "description": "Disallow leading '%' in LIKE, e.g. LIKE foo = '%x' is not allowed."+ },+ "schema-backward-compatibility": {+ "title": "Backward compatibility",+ "description": "MySQL and TiDB support checking whether the schema change is backward compatible."+ }+ },+ "level": {+ "name": "Error Level",+ "error": "Error",+ "warning": "Warning",+ "disabled": "Disabled"+ }+}diff --git a/frontend/src/locales/sql-review/zh-CN.json b/frontend/src/locales/sql-review/zh-CN.jsonnew file mode 100644index 0000000000..45922f7916--- /dev/null+++ b/frontend/src/locales/sql-review/zh-CN.json@@ -0,0 +1,122 @@+{+ "engine": {+ "mysql": "MySQL",+ "common": "通用"+ },+ "category": {+ "engine": "引擎",+ "naming": "命名",+ "statement": "语句",+ "table": "表",+ "column": "列",+ "schema": "Schema"+ },+ "template": {+ "mysql-prod": "针对生产环境的审核策略模板",+ "mysql-dev": "针对开发环境的审核策略模板"+ },+ "rule": {+ "engine-mysql-use-innodb": {+ "title": "使用 InnoDB 作为储存引擎",+ "description": "强制要求使用 InnoDB 作为 MySQL 的储存引擎。"+ },+ "table-require-pk": {+ "title": "强制主键",+ "description": "要求每张表必须有一个主键。"+ },+ "naming-table": {+ "title": "表名命名检查",+ "description": "限制表名命名风格,默认为小写字母_下划线。",+ "component": {+ "name_format": {+ "title": "表命名规则(正则)"+ }+ }+ },+ "naming-column": {+ "title": "列名命名检查",+ "description": "限制列名命名风格,默认为小写字母_下划线。",+ "component": {+ "name_format": {+ "title": "列命名规则(正则)"+ }+ }+ },+ "naming-index-uk": {+ "title": "唯一键命名检查",+ "description": "限制唯一键命名风格,默认为 uk_<表名>_<主键包含的字段名组合>。",+ "component": {+ "name_format": {+ "title": "唯一键命名规则",+ "template": {+ "table": "表名",+ "column_list": "索引包含的字段名,通过 _ 连接"+ }+ }+ }+ },+ "naming-index-fk": {+ "title": "外键命名检查",+ "description": "限制外键命名风格,默认为 fk_<目标表名>_<目标字段名>_<被引用表名>_<被引用字段名>。",+ "component": {+ "name_format": {+ "title": "外键命名规则",+ "template": {+ "referencing_table": "目标表名",+ "referencing_column": "目标字段名",+ "referenced_table": "被引用的表名",+ "referenced_column": "被引用的字段名"+ }+ }+ }+ },+ "naming-index-idx": {+ "title": "索引命名检查",+ "description": "限制索引命名风格,默认为 idx_<表名>_<索引包含的字段名组合>。",+ "component": {+ "name_format": {+ "title": "索引命名规则",+ "template": {+ "table": "表名",+ "column_list": "索引包含的字段名,通过 _ 连接"+ }+ }+ }+ },+ "column-required": {+ "title": "必须包含的字段",+ "description": "强制要求表中必须包含某些字段。",+ "component": {+ "column_list": {+ "title": "必须包含的字段名"+ }+ }+ },+ "column-no-null": {+ "title": "禁止字段为 NULL",+ "description": "表中的字段不允许存在 NULL 值。"+ },+ "statement-select-no-select-all": {+ "title": "禁止 \"SELECT *\"",+ "description": "不允许使用 \"SELECT *\" 语句"+ },+ "statement-where-require": {+ "title": "强制 \"WHERE\"",+ "description": "必须使用 \"WHERE\" 语句"+ },+ "statement-where-no-leading-wildcard-like": {+ "title": "禁止左模糊",+ "description": "WHERE 语句中禁止使用左模糊匹配,例如禁止 LIKE foo = '%x'。"+ },+ "schema-backward-compatibility": {+ "title": "向后兼容",+ "description": "MySQL 和 TiDB 支持检测 schema 变更是否向后兼容"+ }+ },+ "level": {+ "name": "错误等级",+ "error": "错误",+ "warning": "警告",+ "disabled": "禁用"+ }+}diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 97dc80754a..bf1d94e65e 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1439,123 +1439,7 @@"disable": "停用审查策略","enable": "开启审查策略","delete": "删除审核策略",- "category": {- "engine": "引擎",- "naming": "命名",- "statement": "语句",- "table": "表",- "column": "列",- "schema": "Schema"- },- "template": {- "mysql-prod": "针对生产环境的审核策略模板",- "mysql-dev": "针对开发环境的审核策略模板"- },"input-then-press-enter": "输入后按下回车来添加",- "rule": {- "engine-mysql-use-innodb": {- "title": "使用 InnoDB 作为储存引擎",- "description": "强制要求使用 InnoDB 作为 MySQL 的储存引擎。"- },- "table-require-pk": {- "title": "强制主键",- "description": "要求每张表必须有一个主键。"- },- "naming-table": {- "title": "表名命名检查",- "description": "限制表名命名风格,默认为小写字母_下划线。",- "component": {- "name_format": {- "title": "表命名规则(正则)"- }- }- },- "naming-column": {- "title": "列名命名检查",- "description": "限制列名命名风格,默认为小写字母_下划线。",- "component": {- "name_format": {- "title": "列命名规则(正则)"- }- }- },- "naming-index-uk": {- "title": "唯一键命名检查",- "description": "限制唯一键命名风格,默认为 uk_<表名>_<主键包含的字段名组合>。",- "component": {- "name_format": {- "title": "唯一键命名规则",- "template": {- "table": "表名",- "column_list": "索引包含的字段名,通过 _ 连接"- }- }- }- },- "naming-index-fk": {- "title": "外键命名检查",- "description": "限制外键命名风格,默认为 fk_<目标表名>_<目标字段名>_<被引用表名>_<被引用字段名>。",- "component": {- "name_format": {- "title": "外键命名规则",- "template": {- "referencing_table": "目标表名",- "referencing_column": "目标字段名",- "referenced_table": "被引用的表名",- "referenced_column": "被引用的字段名"- }- }- }- },- "naming-index-idx": {- "title": "索引命名检查",- "description": "限制索引命名风格,默认为 idx_<表名>_<索引包含的字段名组合>。",- "component": {- "name_format": {- "title": "索引命名规则",- "template": {- "table": "表名",- "column_list": "索引包含的字段名,通过 _ 连接"- }- }- }- },- "column-required": {- "title": "必须包含的字段",- "description": "强制要求表中必须包含某些字段。",- "component": {- "column_list": {- "title": "必须包含的字段名"- }- }- },- "column-no-null": {- "title": "禁止字段为 NULL",- "description": "表中的字段不允许存在 NULL 值。"- },- "statement-select-no-select-all": {- "title": "禁止 \"SELECT *\"",- "description": "不允许使用 \"SELECT *\" 语句"- },- "statement-where-require": {- "title": "强制 \"WHERE\"",- "description": "必须使用 \"WHERE\" 语句"- },- "statement-where-no-leading-wildcard-like": {- "title": "禁止左模糊",- "description": "WHERE 语句中禁止使用左模糊匹配,例如禁止 LIKE foo = '%x'。"- },- "schema-backward-compatibility": {- "title": "向后兼容",- "description": "MySQL 和 TiDB 支持检测 schema 变更是否向后兼容"- }- },- "error-level": {- "name": "错误等级",- "error": "错误",- "warning": "警告",- "disabled": "禁用"- },"create": {"breadcrumb": "创建审核策略","basic-info": {diff --git a/frontend/src/plugins/i18n.ts b/frontend/src/plugins/i18n.tsindex e58ea39efe..bb36f3486c 100644--- a/frontend/src/plugins/i18n.ts+++ b/frontend/src/plugins/i18n.ts@@ -15,20 +15,34 @@ if (locale === "en") {// import i18n resources// https://vitejs.dev/guide/features.html#glob-import-const messages = Object.fromEntries(- Object.entries(import.meta.globEager("../locales/*.json")).map(- ([key, value]) => {- const name = key.slice(localPathPrefix.length, -5);- return [name, value.default];- }- )-);+const mergedLocalMessage = Object.entries(+ import.meta.globEager("../locales/**/*.json")+).reduce((map, [key, value]) => {+ const name = key.slice(localPathPrefix.length, -5);+ const sections = name.split("/");+ if (sections.length === 1) {+ map[name] = value.default;+ } else {+ const file = sections.slice(-1)[0];+ const sectionsName = sections[0];+ const existed = map[file] || {};+ map[file] = {+ ...existed,+ [sectionsName]: {+ ...(existed[sectionsName] || {}),+ ...value.default,+ },+ };+ }++ return map;+}, {} as { [k: string]: any });const i18n = createI18n({legacy: false,locale,globalInjection: true,- messages,+ messages: mergedLocalMessage,fallbackLocale: "en-US",});diff --git a/frontend/src/types/schemaSystem.ts b/frontend/src/types/schemaSystem.tsindex 39c6836cd7..56e8bdf821 100644--- a/frontend/src/types/schemaSystem.ts+++ b/frontend/src/types/schemaSystem.ts@@ -304,8 +304,8 @@ export const getRuleLocalization = (const { t } = useI18n();const key = getRuleLocalizationKey(type);- const title = t(`schema-review-policy.rule.${key}.title`);- const description = t(`schema-review-policy.rule.${key}.description`);+ const title = t(`sql-review.rule.${key}.title`);+ const description = t(`sql-review.rule.${key}.description`);return {title,diff --git a/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vue b/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vueindex fc10d027ee..f8dfd14881 100644--- a/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vue+++ b/frontend/src/views/SettingWorkspaceSchemaReviewDetail.vue@@ -100,7 +100,7 @@:for="engine.id"class="ml-2 items-center text-sm text-gray-600">- {{ $t(`engine.${engine.id.toLowerCase()}`) }}+ {{ $t(`sql-review.engine.${engine.id.toLowerCase()}`) }}<spanclass="items-center px-2 py-0.5 rounded-full bg-gray-200 text-gray-800">@@ -110,7 +110,7 @@</div></div><div class="flex flex-wrap gap-x-3">- <span>{{ $t("schema-review-policy.error-level.name") }}:</span>+ <span>{{ $t("sql-review.level.name") }}:</span><divv-for="level in errorLevelList":key="level.id"@@ -128,9 +128,7 @@:for="level.id"class="ml-2 items-center text-sm text-gray-600">- {{- $t(`schema-review-policy.error-level.${level.id.toLowerCase()}`)- }}+ {{ $t(`sql-review.level.${level.id.toLowerCase()}`) }}<spanclass="items-center px-2 py-0.5 rounded-full bg-gray-200 text-gray-800">@@ -340,7 +338,7 @@ const toggleCheckedLevel = (level: RuleLevel) => {const categoryFilterList = computed((): CategoryFilterItem[] => {return convertToCategoryList(selectedRuleList.value).map((c) => ({id: c.id,- name: t(`schema-review-policy.category.${c.id.toLowerCase()}`),+ name: t(`sql-review.category.${c.id.toLowerCase()}`),}));});