Skip to content

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

fix: localization file merge (#2704)

ecmadao1ec5e272eb1e
diff --git a/frontend/src/plugins/i18n.ts b/frontend/src/plugins/i18n.ts
index 03584d1b81..6bc07c581d 100644
--- a/frontend/src/plugins/i18n.ts
+++ b/frontend/src/plugins/i18n.ts
@@ -1,6 +1,7 @@
import { App } from "vue";
import { createI18n } from "vue-i18n";
import { useLocalStorage } from "@vueuse/core";
+import _ from "lodash-es";
const localPathPrefix = "../locales/";
const validLocaleList = ["en-US", "zh-CN"];
@@ -39,22 +40,19 @@ const getValidLocale = () => {
// import i18n resources
// https://vitejs.dev/guide/features.html#glob-import
const mergedLocalMessage = Object.entries(
- import.meta.globEager("../locales/**/*.json")
+ import.meta.glob("../locales/**/*.json", { eager: true })
).reduce((map, [key, value]) => {
const name = key.slice(localPathPrefix.length, -5);
const sections = name.split("/");
if (sections.length === 1) {
- map[name] = value.default;
+ map[name] = _.merge(value.default, map[name] || {});
} else {
const file = sections.slice(-1)[0];
const sectionsName = sections[0];
const existed = map[file] || {};
map[file] = {
...existed,
- [sectionsName]: {
- ...(existed[sectionsName] || {}),
- ...value.default,
- },
+ [sectionsName]: _.merge(value.default, existed[sectionsName] || {}),
};
}