Skip to content

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

feat: i18n with router (#218)

STEVEN9e1a1fc37d85
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vue
index ad650971e1..78a8011673 100644
--- a/frontend/src/components/Breadcrumb.vue
+++ b/frontend/src/components/Breadcrumb.vue
@@ -51,6 +51,7 @@
import { computed, ComputedRef } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
+import { useI18n } from "vue-i18n";
import {
RouterSlug,
Bookmark,
@@ -71,6 +72,7 @@ export default {
setup() {
const store = useStore();
const currentRoute = useRouter().currentRoute;
+ const { t } = useI18n();
const currentUser: ComputedRef<Principal> = computed(() =>
store.getters["auth/currentUser"]()
@@ -106,12 +108,12 @@ export default {
const list: Array<BreadcrumbItem> = [];
if (environmentSlug) {
list.push({
- name: "Environment",
+ name: t("common.environment"),
path: "/environment",
});
} else if (projectSlug) {
list.push({
- name: "Project",
+ name: t("common.project"),
path: "/project",
});
@@ -126,12 +128,12 @@ export default {
}
} else if (instanceSlug) {
list.push({
- name: "Instance",
+ name: t("common.instance"),
path: "/instance",
});
} else if (databaseSlug) {
list.push({
- name: "Database",
+ name: t("common.database"),
path: "/db",
});
@@ -145,14 +147,14 @@ export default {
});
if (migrationHistory) {
list.push({
- name: "Migration",
+ name: t("common.migration"),
path: `/db/${databaseSlug}#migration-history`,
});
}
}
} else if (versionControlSlug) {
list.push({
- name: "Version Control",
+ name: t("common.version-control"),
path: "/setting/version-control",
});
}
diff --git a/frontend/src/components/ProjectWebhookPanel.vue b/frontend/src/components/ProjectWebhookPanel.vue
index f5160b708a..4a330783f3 100644
--- a/frontend/src/components/ProjectWebhookPanel.vue
+++ b/frontend/src/components/ProjectWebhookPanel.vue
@@ -6,7 +6,7 @@
class="btn-primary ml-3 inline-flex justify-center py-2 px-4"
@click.prevent="addProjectWebhook"
>
- {{ $t("project.webhook.create-webhook") }}
+ {{ $t("project.webhook.add-a-webhook") }}
</button>
</div>
<div class="pt-4">
diff --git a/frontend/src/composables/useLanguage.ts b/frontend/src/composables/useLanguage.ts
index 8649fa2e3d..27f6adb8ae 100644
--- a/frontend/src/composables/useLanguage.ts
+++ b/frontend/src/composables/useLanguage.ts
@@ -1,5 +1,6 @@
import { useI18n } from "vue-i18n";
import { useLocalStorage } from "@vueuse/core";
+import { useRouter } from "vue-router";
/**
* Language hook for i18n
@@ -7,6 +8,7 @@ import { useLocalStorage } from "@vueuse/core";
*/
const useLanguage = () => {
const { availableLocales, locale } = useI18n();
+ const currentRoute = useRouter().currentRoute;
const storage = useLocalStorage("bytebase_options", {}) as any;
const setLocale = (lang: string) => {
@@ -16,6 +18,10 @@ const useLanguage = () => {
language: lang,
},
};
+ if (currentRoute.value.meta.title) {
+ const title = currentRoute.value.meta.title(currentRoute.value);
+ document.title = title || "Bytebase";
+ }
};
const toggleLocales = () => {
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index 5fcff748f6..254284db76 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -11,6 +11,7 @@ common:
wecom: WeCom
overview: Overview
migration-history: Migration History
+ webhook: Webhook
webhooks: Webhooks
key: Key
workflow: Workflow
@@ -29,6 +30,7 @@ common:
cancel: Cancel
comment: Comment
home: Home
+ setting: Setting
settings: Settings
project: Project
projects: Projects
@@ -114,7 +116,7 @@ common:
sensitive-placeholder: sensitive - write only
enabled: enabled
default: default
- version-control: version control
+ version-control: Version Control
restore: Restore
detailed-guide: detailed guide
workspace: workspace
@@ -144,6 +146,8 @@ common:
grant: Grant
read-only: Read-only
connection-string: Connection string
+ agents: Agents
+ billings: Billings
error-page:
go-back-home: Go back home
anomaly-center: Anomaly Center
@@ -538,6 +542,7 @@ auth:
title: Forgot your password?
content: Please contact your Bytebase Admin to reset your password.
return-to-sign-in: Return to Sign in
+ password-forgot: Forgot Password
password-reset:
title: Reset your password
content: Enter your email address and we will send you a password reset link
@@ -702,6 +707,7 @@ repository:
restore-ui-workflow-success: Successfully restored to UI workflow
update-version-control-config-success: Successfully updated @:common.version-control config
setup-wizard-guide: If you encounter errors during the process, please refer to our {guide}
+ add-git-provider: Add Git provider
choose-git-provider: Choose Git provider
select-repository: Select repository
configure-deploy: Configure deploy
@@ -809,7 +815,8 @@ project:
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 webhook
+ add-a-webhook: Add a webhook
+ create-webhook: Create webhook
last-updated-by: Last updated bu
destination: Destination
webhook-url: Webhook url
@@ -951,6 +958,7 @@ datasource:
user-list: User list
revoke-access: Are you sure to revoke '{0}' access from '{1}'?
grant-data-source: Grant data source
+ grant-database: Grant database
requested-issue: Requested issue
successfully-revoked-member-principal-name-access-from-props-datasource-name: Successfully revoked '{0}' access from '{1}'.
your-issue-id-e-g-1234: Your issue id (e.g. 1234)
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index 0b7da1892b..df671ed9dc 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -11,6 +11,7 @@ common:
wecom: 企业微信
overview: 概览
migration-history: 迁移历史
+ webhook: Webhook
webhooks: Webhook
key: 键值
workflow: 工作流
@@ -29,6 +30,7 @@ common:
cancel: 取消
comment: 评论
home: 主页
+ setting: 设置
settings: 设置
project: 项目
projects: 项目
@@ -144,6 +146,8 @@ common:
grant: 授予
read-only: 只读
connection-string: 连接字符串
+ agents: Agents
+ billings: 计费
error-page:
go-back-home: 回到主页
anomaly-center: 异常中心
@@ -492,6 +496,7 @@ auth:
title: 忘记了您的密码?
content: 请联系的您的 Bytebase 管理员重置密码
return-to-sign-in: 返回登录
+ password-forgot: 忘记密码
password-reset:
title: 重置您的密码
content: 我们会将重置密码链接发送到您的邮箱
@@ -626,6 +631,7 @@ repository:
restore-ui-workflow-success: 成功重置到 UI 工作流
update-version-control-config-success: 成功更新@:common.version-control配置
setup-wizard-guide: 如果您在过程中遇到问题, 请参考{guide}
+ add-git-provider: 添加 Git 提供方
choose-git-provider: 选择 Git 提供方
select-repository: 选择仓库
configure-deploy: 配置部署
@@ -714,7 +720,8 @@ project:
success-deleted-prompt: 成功删除 {name} webhook.
success-tested-prompt: 测试 webhook 事件成功.
fail-tested-title: 测试 webhook 事件失败.
- create-webhook: 添加 webhook
+ add-a-webhook: 添加 webhook
+ create-webhook: 创建 webhook
last-updated-by: 最后修改人
destination: 外部应用
webhook-url: Webhook url
@@ -826,6 +833,7 @@ datasource:
user-list: 用户列表
revoke-access: 您确定要取消 '{0}' 对 '{1}' 的访问权限?
grant-data-source: 授予数据源
+ grant-database: 授权数据库
requested-issue: 申请工单
successfully-revoked-member-principal-name-access-from-props-datasource-name: 成功取消 '{0}' 对 '{1}' 的访问权限。
your-issue-id-e-g-1234: 您的工单 id (例如 1234)
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 6eca7ecee1..dfa90aec86 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -10,6 +10,7 @@ import DashboardLayout from "../layouts/DashboardLayout.vue";
import DatabaseLayout from "../layouts/DatabaseLayout.vue";
import InstanceLayout from "../layouts/InstanceLayout.vue";
import SplashLayout from "../layouts/SplashLayout.vue";
+import { t } from "../plugins/i18n";
import { store } from "../store";
import { Database, QuickActionType } from "../types";
import { idFromSlug, isDBAOrOwner, isOwner } from "../utils";
@@ -36,7 +37,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "",
name: SIGNIN_MODULE,
- meta: { title: () => "Signin" },
+ meta: { title: () => t("common.sign-in") },
component: Signin,
alias: "signin",
props: true,
@@ -44,7 +45,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "signup",
name: SIGNUP_MODULE,
- meta: { title: () => "Signup" },
+ meta: { title: () => t("common.sign-up") },
component: Signup,
props: true,
},
@@ -66,7 +67,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "password-forgot",
name: PASSWORD_FORGOT_MODULE,
- meta: { title: () => "Forgot Password" },
+ meta: { title: () => `${t("auth.password-forgot")}` },
component: () => import("../views/auth/PasswordForgot.vue"),
props: true,
},
@@ -181,7 +182,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "inbox",
name: "workspace.inbox",
- meta: { title: () => "Inbox" },
+ meta: { title: () => t("common.inbox") },
components: {
content: () => import("../views/Inbox.vue"),
leftSidebar: DashboardSidebar,
@@ -194,7 +195,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "anomaly-center",
name: "workspace.anomaly-center",
- meta: { title: () => "Anomaly Center" },
+ meta: { title: () => t("anomaly-center") },
components: {
content: () => import("../views/AnomalyCenterDashboard.vue"),
leftSidebar: DashboardSidebar,
@@ -207,7 +208,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "archive",
name: "workspace.archive",
- meta: { title: () => "Archive" },
+ meta: { title: () => t("common.archive") },
components: {
content: () => import("../views/Archive.vue"),
leftSidebar: DashboardSidebar,
@@ -242,7 +243,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "setting",
name: "setting",
- meta: { title: () => "Setting" },
+ meta: { title: () => t("common.setting") },
components: {
content: () => import("../layouts/SettingLayout.vue"),
leftSidebar: () => import("../views/SettingSidebar.vue"),
@@ -255,7 +256,7 @@ const routes: Array<RouteRecordRaw> = [
{
path: "",
name: "setting.profile",
- meta: { title: () => "Profile" },
+ meta: { title: () => t("settings.sidebar.profile") },
component: () => import("../views/ProfileDashboard.vue"),
alias: "profile",
props: true,
@@ -263,35 +264,35 @@ const routes: Array<RouteRecordRaw> = [
{
path: "general",
name: "setting.workspace.general",
- meta: { title: () => "General" },
+ meta: { title: () => t("settings.sidebar.general") },
component: () => import("../views/SettingWorkspaceGeneral.vue"),
props: true,
},
{
path: "agent",
name: "setting.workspace.agent",
- meta: { title: () => "Agents" },
+ meta: { title: () => t("common.agents") },
component: () => import("../views/SettingWorkspaceAgent.vue"),
props: true,
},
{
path: "member",
name: "setting.workspace.member",
- meta: { title: () => "Members" },
+ meta: { title: () => t("settings.sidebar.members") },
component: () => import("../views/SettingWorkspaceMember.vue"),
props: true,
},
{
path: "version-control",
name: "setting.workspace.version-control",
- meta: { title: () => "Version Control" },
+ meta: { title: () => t("settings.sidebar.version-control") },
component: () => import("../views/SettingWorkspaceVCS.vue"),
props: true,
},
{
path: "version-control/new",
name: "setting.workspace.version-control.create",
- meta: { title: () => "Add Git Provider" },
+ meta: { title: () => t("repository.add-git-provider") },
component: () =>
import("../views/SettingWorkspaceVCSCreate.vue"),
props: true,
@@ -312,21 +313,21 @@ const routes: Array<RouteRecordRaw> = [
{
path: "plan",
name: "setting.workspace.plan",
- meta: { title: () => "Plans" },
+ meta: { title: () => t("settings.sidebar.plans") },
component: () => import("../views/SettingWorkspacePlan.vue"),
props: true,
},
{
path: "billing",
name: "setting.workspace.billing",
- meta: { title: () => "Billings" },
+ meta: { title: () => t("common.billings") },
component: () => import("../views/SettingWorkspaceBilling.vue"),
props: true,
},
{
path: "integration/slack",
name: "setting.workspace.integration.slack",
- meta: { title: () => "Slack" },
+ meta: { title: () => t("common.slack") },
component: () =>
import("../views/SettingWorkspaceIntegrationSlack.vue"),
props: true,
@@ -337,7 +338,7 @@ const routes: Array<RouteRecordRaw> = [
path: "issue",
name: "workspace.issue",
meta: {
- title: () => "Issue",
+ title: () => t("common.issue"),
},
components: {
content: () => import("../views/IssueDashboard.vue"),
@@ -349,7 +350,7 @@ const routes: Array<RouteRecordRaw> = [
path: "environment",
name: "workspace.environment",
meta: {
- title: () => "Environment",
+ title: () => t("common.environment"),
quickActionListByRole: () => {
return new Map([
[
@@ -397,7 +398,7 @@ const routes: Array<RouteRecordRaw> = [
path: "project",
name: "workspace.project",
meta: {
- title: () => "Project",
+ title: () => t("common.project"),
quickActionListByRole: () => {
return new Map([
[
@@ -494,7 +495,7 @@ const routes: Array<RouteRecordRaw> = [
path: "webhook/new",
name: "workspace.project.hook.create",
meta: {
- title: () => "Create webhook",
+ title: () => t("project.webhook.create-webhook"),
},
component: () => import("../views/ProjectWebhookCreate.vue"),
props: true,
@@ -507,13 +508,12 @@ const routes: Array<RouteRecordRaw> = [
const projectSlug = route.params.projectSlug as string;
const projectWebhookSlug = route.params
.projectWebhookSlug as string;
- return (
- "Webhook - " +
+ return `${t("common.webhook")} - ${
store.getters["projectWebhook/projectWebhookById"](
idFromSlug(projectSlug),
idFromSlug(projectWebhookSlug)
).name
- );
+ }`;
},
allowBookmark: true,
},
@@ -526,7 +526,7 @@ const routes: Array<RouteRecordRaw> = [
path: "instance",
name: "workspace.instance",
meta: {
- title: () => "Instance",
+ title: () => t("common.instance"),
quickActionListByRole: () => {
return new Map([
["OWNER", ["quickaction.bb.instance.create"]],
@@ -544,7 +544,7 @@ const routes: Array<RouteRecordRaw> = [
path: "db",
name: "workspace.database",
meta: {
- title: () => "Database",
+ title: () => t("common.database"),
quickActionListByRole: () => {
const ownerList: QuickActionType[] = store.getters[
"plan/feature"
@@ -599,7 +599,7 @@ const routes: Array<RouteRecordRaw> = [
path: "db/grant",
name: "workspace.database.grant",
meta: {
- title: () => "Grant database",
+ title: () => t("datasource.grant-database"),
},
components: {
content: () => import("../views/DatabaseGrant.vue"),
@@ -622,7 +622,7 @@ const routes: Array<RouteRecordRaw> = [
title: (route: RouteLocationNormalized) => {
const slug = route.params.databaseSlug as string;
if (slug.toLowerCase() == "new") {
- return "New";
+ return t("common.new");
}
return store.getters["database/databaseById"](
idFromSlug(slug)
@@ -638,7 +638,7 @@ const routes: Array<RouteRecordRaw> = [
name: "workspace.database.table.detail",
meta: {
title: (route: RouteLocationNormalized) => {
- return `Table - ${route.params.tableName}`;
+ return `${t("db.tables")} - ${route.params.tableName}`;
},
allowBookmark: true,
},
@@ -652,14 +652,13 @@ const routes: Array<RouteRecordRaw> = [
title: (route: RouteLocationNormalized) => {
const slug = route.params.dataSourceSlug as string;
if (slug.toLowerCase() == "new") {
- return "New";
+ return t("common.new");
}
- return (
- "Data source - " +
+ return `${t("common.data-source")} - ${
store.getters["dataSource/dataSourceById"](
idFromSlug(slug)
).name
- );
+ }`;
},
allowBookmark: true,
},
@@ -698,7 +697,7 @@ const routes: Array<RouteRecordRaw> = [
title: (route: RouteLocationNormalized) => {
const slug = route.params.instanceSlug as string;
if (slug.toLowerCase() == "new") {
- return "New";
+ return t("common.new");
}
return store.getters["instance/instanceById"](
idFromSlug(slug)
@@ -717,7 +716,7 @@ const routes: Array<RouteRecordRaw> = [
title: (route: RouteLocationNormalized) => {
const slug = route.params.issueSlug as string;
if (slug.toLowerCase() == "new") {
- return "New";
+ return t("common.new");
}
return store.getters["issue/issueById"](idFromSlug(slug)).name;
},