Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: i18n for migration history module part1 (#154)

tianzhou6ee42cc6ca77
diff --git a/frontend/src/components/DatabaseMigrationHistoryPanel.vue b/frontend/src/components/DatabaseMigrationHistoryPanel.vue
index 117fcd6612..c1f2affcf8 100644
--- a/frontend/src/components/DatabaseMigrationHistoryPanel.vue
+++ b/frontend/src/components/DatabaseMigrationHistoryPanel.vue
@@ -11,7 +11,7 @@
space-x-2
"
>
- Migration History
+ {{ $t('migration-history.self') }}
<button
v-if="allowEdit"
type="button"
@@ -19,10 +19,10 @@
:disabled="state.migrationSetupStatus != 'OK'"
@click.prevent="state.showBaselineModal = true"
>
- Establish new baseline
+ {{ $t('migration-history.establish-baseline') }}
</button>
<div>
- <BBSpin v-if="state.loading" :title="'Refreshing history ...'" />
+ <BBSpin v-if="state.loading" :title="$t('migration-history.refreshing-history')" />
</div>
</div>
<MigrationHistoryTable
@@ -34,7 +34,7 @@
v-else
:style="`WARN`"
:title="attentionTitle"
- :action-text="allowConfigInstance ? 'Config instance' : ''"
+ :action-text="allowConfigInstance ? $t('migration-history.config-instance') : ''"
@click-action="configInstance"
/>
</div>
@@ -42,10 +42,10 @@
<BBAlert
v-if="state.showBaselineModal"
:style="'INFO'"
- :ok-text="'Establish baseline'"
- :cancel-text="'Cancel'"
+ :ok-text="$t('migration-history.establish-baseline')"
+ :cancel-text="$t('common.cancel')"
:title="`Establish new baseline for \'${database.name}\'`"
- :description="'Bytebase will use the current schema as the new baseline. You should check that the current schema does reflect the desired state.\n\nFor VCS workflow, there must exist a baseline before any incremental migration change can be applied to the database.'"
+ :description="$t('migration-history.establish-baseline-description')"
@ok="
() => {
doCreateBaseline();
diff --git a/frontend/src/components/MigrationHistoryTable.vue b/frontend/src/components/MigrationHistoryTable.vue
index 58a688cc77..afcb855c98 100644
--- a/frontend/src/components/MigrationHistoryTable.vue
+++ b/frontend/src/components/MigrationHistoryTable.vue
@@ -95,65 +95,10 @@ import { databaseSlug, migrationHistorySlug, secondsToString } from "../utils";
import { BBTableColumn, BBTableSectionDataSource } from "../bbkit/types";
import MigrationHistoryStatusIcon from "./MigrationHistoryStatusIcon.vue";
import { useRouter } from "vue-router";
+import { useI18n } from "vue-i18n";
type Mode = "DATABASE" | "PROJECT";
-const columnListMap: Map<Mode, BBTableColumn[]> = new Map([
- [
- "DATABASE",
- [
- {
- title: "",
- },
- {
- title: "Workflow",
- },
- {
- title: "Version",
- },
- {
- title: "Issue",
- },
- {
- title: "SQL",
- },
- {
- title: "Duration",
- },
- {
- title: "Created",
- },
- {
- title: "Creator",
- },
- ],
- ],
- [
- "PROJECT",
- [
- { title: "" },
- {
- title: "Version",
- },
- {
- title: "Issue",
- },
- {
- title: "SQL",
- },
- {
- title: "Duration",
- },
- {
- title: "Created",
- },
- {
- title: "Creator",
- },
- ],
- ],
-]);
-
export default {
name: "MigrationHistoryTable",
components: { MigrationHistoryStatusIcon },
@@ -174,6 +119,64 @@ export default {
setup(props) {
const router = useRouter();
+ const { t } = useI18n();
+
+ const columnListMap: Map<Mode, BBTableColumn[]> = new Map([
+ [
+ "DATABASE",
+ [
+ {
+ title: "",
+ },
+ {
+ title: t('migration-history.workflow'),
+ },
+ {
+ title: t('common.version'),
+ },
+ {
+ title: t('common.issue'),
+ },
+ {
+ title: "SQL",
+ },
+ {
+ title: t('common.duration'),
+ },
+ {
+ title: t('common.created-at'),
+ },
+ {
+ title: t('common.creator'),
+ },
+ ],
+ ],
+ [
+ "PROJECT",
+ [
+ { title: "" },
+ {
+ title: t('common.version'),
+ },
+ {
+ title: t('common.issue'),
+ },
+ {
+ title: "SQL",
+ },
+ {
+ title: t('common.duration'),
+ },
+ {
+ title: t('common.created-at'),
+ },
+ {
+ title: t('common.creator'),
+ },
+ ],
+ ],
+ ]);
+
const clickHistory = function (section: number, row: number) {
const history = props.historySectionList[section].list[row];
router.push(
diff --git a/frontend/src/components/ProjectMigrationHistoryPanel.vue b/frontend/src/components/ProjectMigrationHistoryPanel.vue
index 7a5304ddc9..da11828c69 100644
--- a/frontend/src/components/ProjectMigrationHistoryPanel.vue
+++ b/frontend/src/components/ProjectMigrationHistoryPanel.vue
@@ -2,8 +2,7 @@
<div class="flex flex-col space-y-4">
<template v-if="state.migrationHistorySectionList.length > 0">
<div class="text-center textinfolabel">
- For database having migration history, we list up to 5 most recent
- histories below. You can click the database name to view all histories.
+ {{ $t('migration-history.list-limit') }}
</div>
<MigrationHistoryTable
:mode="'PROJECT'"
@@ -16,10 +15,10 @@
<div class="text-center">
<heroicons-outline:inbox class="mx-auto w-16 h-16 text-control-light" />
<h3 class="mt-2 text-sm font-medium text-main">
- Do not find migration history from any database in this project.
+ {{ $t('migration-history.no-history-in-project') }}
</h3>
<p class="mt-1 text-sm text-control-light">
- Migration history is recorded whenever the database schema is altered.
+ {{ $t('migration-history.recording-info') }}
</p>
</div>
</template>
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index ce8367d59d..404516d853 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -30,6 +30,14 @@ common:
owner: Switch to Owner
developer: Switch to Developer
assignee: Assignee
+ creator: Creator
+ version: Version
+ issue: Issue
+ duration: Duration
+ created-at: Created
+ commit: Commit
+ statement: Statement
+ snapshot: Snapshot
error-page:
go-back-home: Go back home
anomaly-center: Anomaly Center
@@ -164,3 +172,24 @@ quick-start:
notice:
title: Quickstart guide dismissed
desc: You can still bring it back later from the top right menu
+migration-history:
+ self: Migration History
+ workflow: Workflow
+ commit-info: by {author} at {time}
+ no-schema-change: this migration has no schema change
+ show-diff: Show diff
+ left-vs-right: Prev (left) vs This version (right)
+ schema-snapshot-after-migration: The schema snapshot recorded after applying this migration
+ list-limit: >-
+ For database having migration history, we list up to 5 most recent histories
+ below. You can click the database name to view all histories.
+ no-history-in-project: Do not find migration history from any database in this project.
+ recording-info: Migration history is recorded whenever the database schema is altered.
+ establish-baseline: Establish new baseline
+ refreshing-history: Refreshing history ...
+ config-instance: Config instance
+ establish-baseline-description: >-
+ Bytebase will use the current schema as the new baseline. You should check
+ that the current schema does reflect the desired state. For VCS workflow,
+ there must exist a baseline before any incremental migration change can be
+ applied to the database.
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index ed89daa3c4..4cb26ef4e3 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -30,6 +30,14 @@ common:
owner: 切换到所有者
developer: 切换到开发者
assignee: 审核人
+ creator: 创建人
+ version: 版本
+ issue: 工单
+ duration: 时长
+ created-at: 创建于
+ commit: 提交
+ statement: 语句
+ snapshot: 快照
error-page:
go-back-home: 回到主页
anomaly-center: 异常中心
@@ -147,3 +155,22 @@ quick-start:
notice:
title: 快速入门导览已关闭
desc: 您稍后仍可以从右上角的菜单中再次打开快速入门导览
+migration-history:
+ self: 迁移历史
+ workflow: 工作流
+ commit-info: '由 {author} 于 {time}'
+ no-schema-change: 本次迁移没有任何 Schema 的改动
+ show-diff: 显示差异
+ left-vs-right: 之前 (左) vs 当前版本 (右)
+ schema-snapshot-after-migration: 完成这次迁移后的 schema 快照
+ list-limit: >-
+ 对于有迁移历史的数据库,我们会在下面最多列出5条记录。您可以点击数据库名称去进一步查看全部的记录。
+ no-history-in-project: 这个项目下没有发现任何数据库有迁移历史。
+ recording-info: 每当数据库 schema 变更时,我们便会记录下迁移历史。
+ establish-baseline: 建立新的基线
+ refreshing-history: 刷新历史中 ...
+ config-instance: 配置实例
+ establish-baseline-description: >-
+ Bytebase 将用当前的 schema 作为新的基线。你应该检查当前的基线确实反映了期望的状态。
+ 对于 VCS 工作流来说,也只有在建立起基线的前提下,才能进行数据库变更。
+
diff --git a/frontend/src/views/MigrationHistoryDetail.vue b/frontend/src/views/MigrationHistoryDetail.vue
index 2f87ba21f6..5d02e1637b 100644
--- a/frontend/src/views/MigrationHistoryDetail.vue
+++ b/frontend/src/views/MigrationHistoryDetail.vue
@@ -15,7 +15,7 @@
<div class="pt-2 flex items-center space-x-2">
<MigrationHistoryStatusIcon :status="migrationHistory.status" />
<h1 class="text-xl font-bold leading-6 text-main truncate">
- Version {{ migrationHistory.version }}
+ {{ $t('common.version') }} {{ migrationHistory.version }}
</h1>
</div>
<p class="text-control">
@@ -29,9 +29,9 @@
md:space-y-0 md:flex-row md:flex-wrap
"
>
- <dt class="sr-only">Issue</dt>
+ <dt class="sr-only">{{ $t('common.issue') }}</dt>
<dd class="flex items-center text-sm md:mr-4">
- <span class="textlabel">Issue&nbsp;-&nbsp;</span>
+ <span class="textlabel">{{ $t('common.issue') }}&nbsp;-&nbsp;</span>
<router-link
:to="`/issue/${migrationHistory.issueId}`"
class="normal-link"
@@ -39,19 +39,19 @@
{{ migrationHistory.issueId }}
</router-link>
</dd>
- <dt class="sr-only">Duration</dt>
+ <dt class="sr-only">{{ $t('common.duration') }}</dt>
<dd class="flex items-center text-sm md:mr-4">
- <span class="textlabel">Duration&nbsp;-&nbsp;</span>
+ <span class="textlabel">{{ $t('common.duration') }}&nbsp;-&nbsp;</span>
{{ secondsToString(migrationHistory.executionDuration) }}
</dd>
- <dt class="sr-only">Creator</dt>
+ <dt class="sr-only">{{ $t('common.creator') }}</dt>
<dd class="flex items-center text-sm md:mr-4">
- <span class="textlabel">Creator&nbsp;-&nbsp;</span>
+ <span class="textlabel">{{ $t('common.creator') }}&nbsp;-&nbsp;</span>
{{ migrationHistory.creator }}
</dd>
- <dt class="sr-only">Created</dt>
+ <dt class="sr-only">{{ $t('common.created-at') }}</dt>
<dd class="flex items-center text-sm md:mr-4">
- <span class="textlabel">Created&nbsp;-&nbsp;</span>
+ <span class="textlabel">{{ $t('common.created-at') }}&nbsp;-&nbsp;</span>
{{ humanizeTs(migrationHistory.createdTs) }} by
{{ `version ${migrationHistory.releaseVersion}` }}
</dd>
@@ -73,7 +73,7 @@
{{ `${vcsBranch}@${pushEvent.repositoryFullPath}` }}
</a>
<span>
- commit
+ {{ $t('common.commit') }}
<a
:href="pushEvent.fileCommit.url"
target="_blank"
@@ -82,9 +82,14 @@
{{ pushEvent.fileCommit.id.substring(0, 7) }}:
</a>
<span class="text-main">{{ pushEvent.fileCommit.title }}</span>
- by
- {{ pushEvent.authorName }} at
- {{ moment(pushEvent.fileCommit.createdTs * 1000).format("LLL") }}
+ <i18n-t keypath="migration-history.commit-info" >
+ <template v-slot:author>
+ {{ pushEvent.authorName }}
+ </template>
+ <template v-slot:time>
+ {{ moment(pushEvent.fileCommit.createdTs * 1000).format("LLL") }}
+ </template>
+ </i18n-t>
</span>
</div>
</div>
@@ -96,7 +101,7 @@
href="#statement"
class="flex items-center text-lg text-main mb-2 hover:underline"
>
- Statement
+ {{ $t('common.statement') }}
<button
tabindex="-1"
class="btn-icon ml-1"
@@ -111,9 +116,9 @@
<a
id="schema"
href="#schema"
- class="flex items-center text-lg text-main mt-6 hover:underline"
+ class="flex items-center text-lg text-main mt-6 hover:underline capitalize"
>
- Schema Snapshot
+ Schema {{ $t('common.snapshot') }}
<button
tabindex="-1"
class="btn-icon ml-1"
@@ -125,7 +130,7 @@
<div class="flex flex-row items-center space-x-2 mt-2">
<BBSwitch
v-if="migrationHistory.schemaPrev != migrationHistory.schema"
- :label="'Show diff'"
+ :label="$t('migration-history.show-diff')"
:value="state.showDiff"
@toggle="
(on) => {
@@ -136,15 +141,15 @@
<div class="textinfolabel">
{{
state.showDiff
- ? "Prev (left) vs This version (right)"
- : "The schema snapshot recorded after applying this migration version"
+ ? $t('migration-history.left-vs-right')
+ : $t('migration-history.schema-snapshot-after-migration')
}}
</div>
<div
v-if="migrationHistory.schemaPrev == migrationHistory.schema"
class="text-sm font-normal text-accent"
>
- (this migration has no schema change)
+ ({{ $t('migration-history.no-schema-change') }})
</div>
</div>
<code-diff