Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(i18n): added i18n support to project module (part2, end story) (#200)
Luke Zhou9084efdedd3b
diff --git a/frontend/src/components/ProjectCreate.vue b/frontend/src/components/ProjectCreate.vueindex ae35418121..da26ab4214 100644--- a/frontend/src/components/ProjectCreate.vue+++ b/frontend/src/components/ProjectCreate.vue@@ -37,14 +37,14 @@class="btn-normal py-2 px-4"@click.prevent="cancel">- Cancel+ {{ $t("common.cancel") }}</button><buttonclass="btn-primary ml-3 inline-flex justify-center py-2 px-4":disabled="!allowCreate"@click.prevent="create">- Create+ {{ $t("common.create") }}</button></div></form>@@ -57,6 +57,7 @@ import { useRouter } from "vue-router";import isEmpty from "lodash-es/isEmpty";import { Project, ProjectCreate } from "../types";import { projectSlug, randomString } from "../utils";+import { useI18n } from "vue-i18n";interface LocalState {project: ProjectCreate;@@ -69,6 +70,7 @@ export default {setup(props, { emit }) {const store = useStore();const router = useRouter();+ const { t } = useI18n();const state = reactive<LocalState>({project: {@@ -107,7 +109,9 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "SUCCESS",- title: `Successfully created project '${createdProject.name}'.`,+ title: t("project.create-modal.success-prompt", {+ name: createdProject.name,+ }),});router.push(`/project/${projectSlug(createdProject)}`);diff --git a/frontend/src/components/ProjectGeneralSettingPanel.vue b/frontend/src/components/ProjectGeneralSettingPanel.vueindex 6e00342739..102c6bf5a7 100644--- a/frontend/src/components/ProjectGeneralSettingPanel.vue+++ b/frontend/src/components/ProjectGeneralSettingPanel.vue@@ -57,6 +57,7 @@ import { computed, PropType, reactive } from "vue";import { useStore } from "vuex";import isEmpty from "lodash-es/isEmpty";import { DEFAULT_PROJECT_ID, Project, ProjectPatch } from "../types";+import { useI18n } from "vue-i18n";interface LocalState {name: string;@@ -77,6 +78,7 @@ export default {},setup(props) {const store = useStore();+ const { t } = useI18n();const state = reactive<LocalState>({name: props.project.name,@@ -111,10 +113,12 @@ export default {projectPatch,}).then((updatedProject: Project) => {- store.dispatch("notification/pushNotification", {+ store.dispatch("notification/", {module: "bytebase",style: "SUCCESS",- title: `Successfully updated ${subject}.`,+ title: t("project.settings.success-updated-prompt", {+ subject: subject,+ }),});state.name = updatedProject.name;state.key = updatedProject.key;diff --git a/frontend/src/components/ProjectMemberPanel.vue b/frontend/src/components/ProjectMemberPanel.vueindex 3d064cf4f1..af427ce679 100644--- a/frontend/src/components/ProjectMemberPanel.vue+++ b/frontend/src/components/ProjectMemberPanel.vue@@ -89,6 +89,7 @@ import {UNKNOWN_ID,} from "../types";import { isOwner, isProjectOwner } from "../utils";+import { useI18n } from "vue-i18n";interface LocalState {principalId: PrincipalId;@@ -107,6 +108,7 @@ export default {},setup(props) {const store = useStore();+ const { t } = useI18n();const currentUser = computed(() => store.getters["auth/currentUser"]());@@ -189,7 +191,9 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "SUCCESS",- title: `Successfully added ${member.principal.name} to the project.`,+ title: t("project.settings.success-member-added-prompt", {+ name: member.principal.name,+ }),});});diff --git a/frontend/src/components/ProjectMemberTable.vue b/frontend/src/components/ProjectMemberTable.vueindex b6dfc864f4..15c38ba363 100644--- a/frontend/src/components/ProjectMemberTable.vue+++ b/frontend/src/components/ProjectMemberTable.vue@@ -259,7 +259,9 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "INFO",- title: `Successfully revoked ${member.principal.name} access from the project.`,+ title: t("project.settings.success-menber-deleted-prompt", {+ name: member.principal.name,+ }),});});};diff --git a/frontend/src/components/ProjectWebhookCard.vue b/frontend/src/components/ProjectWebhookCard.vueindex 3cc37d4e93..6ccf94926a 100644--- a/frontend/src/components/ProjectWebhookCard.vue+++ b/frontend/src/components/ProjectWebhookCard.vue@@ -121,7 +121,7 @@ export default {const activityListStr = computed(() => {const list = props.projectWebhook.activityList.map((activity) => {- for (const item of PROJECT_HOOK_ACTIVITY_ITEM_LIST) {+ for (const item of PROJECT_HOOK_ACTIVITY_ITEM_LIST()) {if (item.activity == activity) {return item.title;}diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vueindex 7d73160d35..284bbca86d 100644--- a/frontend/src/components/ProjectWebhookForm.vue+++ b/frontend/src/components/ProjectWebhookForm.vue@@ -6,7 +6,7 @@</label><div class="mt-1 grid grid-cols-1 gap-4 sm:grid-cols-6"><template- v-for="(item, index) in PROJECT_HOOK_TYPE_ITEM_LIST"+ v-for="(item, index) in PROJECT_HOOK_TYPE_ITEM_LIST()":key="index"><div@@ -185,7 +185,7 @@{{ $t("project.webhook.triggering-activity") }}</div><div- v-for="(item, index) in PROJECT_HOOK_ACTIVITY_ITEM_LIST"+ v-for="(item, index) in PROJECT_HOOK_ACTIVITY_ITEM_LIST()":key="index"class="mt-4 space-y-4">@@ -398,7 +398,9 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "SUCCESS",- title: `Successfully created webhook "${webhook.name}".`,+ title: t("project.webhook.success-created-prompt", {+ name: webhook.name,+ }),});router.push({name: "workspace.project.hook.detail",@@ -430,7 +432,9 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "SUCCESS",- title: `Successfully updated webhook "${webhook.name}".`,+ title: t("project.webhook.success-updated-prompt", {+ name: webhook.name,+ }),});});};@@ -446,7 +450,9 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "SUCCESS",- title: `Successfully deleted webhook "${name}".`,+ title: t("project.webhook.success-deleted-prompt", {+ name: name,+ }),});cancel();});diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.ymlindex d2515e2089..287d11e628 100644--- a/frontend/src/locales/en.yml+++ b/frontend/src/locales/en.yml@@ -682,8 +682,9 @@ project:project-name: '@:common.project @:common.name'key: '@:common.key'key-hint: (Uppercase letters identifying your project)- cancel: '@:common.cancel'- confirm: '@:common.create'+ cancel: "@:common.cancel"+ confirm: "@:common.create"+ success-prompt: Successfully created project {name}.overview:view-all: View allview-all-closed: View all closed@@ -698,6 +699,11 @@ project:No database belongs to this project. You can add database by clicking{newDb} or {transferInDb} from the top action bar.webhook:+ success-created-prompt: Successfully created webhook {name}.+ success-updated-prompt: Successfully updated webhook {name}.+ success-deleted-prompt: Successfully deleted webhook {name}.+ success-tested-prompt: Test webhook event OK.+ fail-tested-title: Test webhook event failed.create-webhook: Add a webhooklast-updated-by: Last updated budestination: Destination@@ -737,6 +743,9 @@ project:title: Issue comment creationlabel: When new issue comment has been createdsettings:+ success-updated-prompt: Successfully updated {subject}.+ success-member-added-prompt: Successfully added {name} to the project.+ success-member-deleted-prompt: Successfully revoked {name} access from the project.member-placeholder: Select usermanage-member: Manage membersadd-member: Add memberdiff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.ymlindex 999d2d99e3..d22c2c59f0 100644--- a/frontend/src/locales/zh-CN.yml+++ b/frontend/src/locales/zh-CN.yml@@ -618,20 +618,23 @@ project:project-name: '@:common.project @:common.name'key: '@:common.key'key-hint: ( 请使用大写字母来命名您的项目 )- cancel: '@:common.cancel'- confirm: '@:common.create'+ cancel: "@:common.cancel"+ confirm: "@:common.create"+ success-prompt: 成功创建 {name}.overview:view-all: 查看所有view-all-closed: 查看所有结束的工单recent-activity: 近期@.lower:{'common.activities'}in-progress: 进行中recently-closed: 近期结束- info-slot-content: >-- Bytebase periodically syncs the instance schema. Newly synced databases- are first placed in this default project. User should transfer them to the- proper application project.+ info-slot-content: Bytebase 会定时同步实例的 schema,新同步的数据库会首先被置于默认项目中,之后您可以再将他们转移到适当的项目中。no-db-prompt: 没有数据库属于当前项目 您可以通过点击位于上方菜单栏中的 {newDb} 或者 {transferInDb} 来添加数据库.webhook:+ success-created-prompt: 成功创建 {name} webhook.+ success-updated-prompt: 成功更新 {name} webhook.+ success-deleted-prompt: 成功删除 {name} webhook.+ success-tested-prompt: 测试 webhook 事件成功.+ fail-tested-title: 测试 webhook 事件失败.create-webhook: 添加 webhooklast-updated-by: 最后修改人destination: 外部应用@@ -647,24 +650,27 @@ project:how-to-protect: 您可以通过添加 'Bytebase' 到您的 webhook 关键字白名单中来保护您的 webhookview-doc: '{destination} 的官方文档'deletion:- btn-text: Delete this webhook+ btn-text: 删除这个 webhookactivity-item:issue-creation:- title: Issue creation- label: When new issue has been created+ title: 创建@:common.issue+ label: 当一个新的工单被创建issue-status-change:- title: Issue status change- label: When issue status has changed+ title: 工单状态变更+ label: 当一个工单的状态发生变更issue-task-status-change:- title: Issue task status change- label: When issue's enclosing task status has changed+ title: 工单任务状态变更+ label: 当一个工单包含的任务状态发生了变更issue-info-change:- title: Issue info change- label: When issue info (e.g. assignee, title, description) has changed+ title: 工单信息变更+ label: "当一个工单的信息 (比如: 分配人, 标题, 描述) 发生了变更"issue-comment-creation:- title: Issue comment creation- label: When new issue comment has been created+ title: 工单被评论+ label: 当新的工单评论被创建settings:+ success-updated-prompt: 成功更新 {subject}.+ success-member-added-prompt: 成功将 {name} 添加到当前项目中.+ success-member-deleted-prompt: 成功将 {name} 从当前项目移除.member-placeholder: 选择用户manage-member: 管理成员add-member: 添加成员diff --git a/frontend/src/plugins/i18n.ts b/frontend/src/plugins/i18n.tsindex 62f996b7d2..ad91d53100 100644--- a/frontend/src/plugins/i18n.ts+++ b/frontend/src/plugins/i18n.ts@@ -18,14 +18,16 @@ const messages = Object.fromEntries());-const install = (app: App) => {- const i18n = createI18n({- legacy: false,- locale,- globalInjection: true,- messages,- });+const i18n = createI18n({+ legacy: false,+ locale,+ globalInjection: true,+ messages,+});++export const t = i18n.global.t;+const install = (app: App) => {app.use(i18n);};diff --git a/frontend/src/types/projectWebhook.ts b/frontend/src/types/projectWebhook.tsindex 98ef6a053b..eff04a3c31 100644--- a/frontend/src/types/projectWebhook.ts+++ b/frontend/src/types/projectWebhook.ts@@ -1,6 +1,7 @@import { ActivityType } from "./activity";import { MemberId, ProjectId } from "./id";import { Principal } from "./principal";+import { t } from "../plugins/i18n";type ProjectWebhookTypeItem = {type: string;@@ -8,38 +9,39 @@ type ProjectWebhookTypeItem = {urlPrefix: string;};-export const PROJECT_HOOK_TYPE_ITEM_LIST: ProjectWebhookTypeItem[] = [- {- type: "bb.plugin.webhook.slack",- name: "Slack",- urlPrefix: "https://hooks.slack.com/",- },- {- type: "bb.plugin.webhook.discord",- name: "Discord",- urlPrefix: "https://discord.com/api/webhooks",- },- {- type: "bb.plugin.webhook.teams",- name: "Teams",- urlPrefix: "",- },- {- type: "bb.plugin.webhook.dingtalk",- name: "DingTalk",- urlPrefix: "https://oapi.dingtalk.com",- },- {- type: "bb.plugin.webhook.feishu",- name: "Feishu",- urlPrefix: "https://open.feishu.cn",- },- {- type: "bb.plugin.webhook.wecom",- name: "WeCom",- urlPrefix: "https://qyapi.weixin.qq.com",- },-];+export const PROJECT_HOOK_TYPE_ITEM_LIST: () => ProjectWebhookTypeItem[] =+ () => [+ {+ type: "bb.plugin.webhook.slack",+ name: t("common.slack"),+ urlPrefix: "https://hooks.slack.com/",+ },+ {+ type: "bb.plugin.webhook.discord",+ name: t("common.discord"),+ urlPrefix: "https://discord.com/api/webhooks",+ },+ {+ type: "bb.plugin.webhook.teams",+ name: t("common.teams"),+ urlPrefix: "",+ },+ {+ type: "bb.plugin.webhook.dingtalk",+ name: t("common.dingtalk"),+ urlPrefix: "https://oapi.dingtalk.com",+ },+ {+ type: "bb.plugin.webhook.feishu",+ name: t("common.feishu"),+ urlPrefix: "https://open.feishu.cn",+ },+ {+ type: "bb.plugin.webhook.wecom",+ name: t("common.wecom"),+ urlPrefix: "https://qyapi.weixin.qq.com",+ },+ ];type ProjectWebhookActivityItem = {title: string;@@ -47,33 +49,34 @@ type ProjectWebhookActivityItem = {activity: ActivityType;};-export const PROJECT_HOOK_ACTIVITY_ITEM_LIST: ProjectWebhookActivityItem[] = [- {- title: "Issue creation",- label: "When new issue has been created",- activity: "bb.issue.create",- },- {- title: "Issue status change",- label: "When issue status has changed",- activity: "bb.issue.status.update",- },- {- title: "Issue task status change",- label: "When issue's enclosing task status has changed",- activity: "bb.pipeline.task.status.update",- },- {- title: "Issue info change",- label: "When issue info (e.g. assignee, title, description) has changed",- activity: "bb.issue.field.update",- },- {- title: "Issue comment creation",- label: "When new issue comment has been created",- activity: "bb.issue.comment.create",- },-];+export const PROJECT_HOOK_ACTIVITY_ITEM_LIST: () => ProjectWebhookActivityItem[] =+ () => [+ {+ title: t("project.webhook.activity-item.issue-creation.title"),+ label: t("project.webhook.activity-item.issue-creation.label"),+ activity: "bb.issue.create",+ },+ {+ title: t("project.webhook.activity-item.issue-status-change.title"),+ label: t("project.webhook.activity-item.issue-status-change.label"),+ activity: "bb.issue.status.update",+ },+ {+ title: t("project.webhook.activity-item.issue-task-status-change.title"),+ label: t("project.webhook.activity-item.issue-task-status-change.label"),+ activity: "bb.pipeline.task.status.update",+ },+ {+ title: t("project.webhook.activity-item.issue-info-change.title"),+ label: t("project.webhook.activity-item.issue-info-change.label"),+ activity: "bb.issue.field.update",+ },+ {+ title: t("project.webhook.activity-item.issue-comment-creation.title"),+ label: t("project.webhook.activity-item.issue-comment-creation.label"),+ activity: "bb.issue.comment.create",+ },+ ];// Project Memberexport type ProjectWebhook = {diff --git a/frontend/src/views/ProjectWebhookDetail.vue b/frontend/src/views/ProjectWebhookDetail.vueindex c3ac75fda3..ff8822b872 100644--- a/frontend/src/views/ProjectWebhookDetail.vue+++ b/frontend/src/views/ProjectWebhookDetail.vue@@ -54,6 +54,7 @@ import ProjectWebhookForm from "../components/ProjectWebhookForm.vue";import { idFromSlug } from "../utils";import { useStore } from "vuex";import { ProjectWebhookTestResult } from "../types";+import { useI18n } from "vue-i18n";export default {name: "ProjectWebhookDetail",@@ -74,6 +75,7 @@ export default {},setup(props) {const store = useStore();+ const { t } = useI18n();const project = computed(() => {return store.getters["project/projectById"](@@ -99,7 +101,7 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "CRITICAL",- title: `Test webhook event failed.`,+ title: t("project.webhook.fail-tested-title"),description: testResult.error,manualHide: true,});@@ -107,7 +109,7 @@ export default {store.dispatch("notification/pushNotification", {module: "bytebase",style: "SUCCESS",- title: `Test webhook event OK.`,+ title: t("project.webhook.success-tested-prompt"),});}});