fix(plugins): localize workbench and filesystem tab titles on locale change

This commit is contained in:
AiLi authored and GitHub committed 2026-09-23 15:45:20 +08:00
1 parent 491565fdda
commit 571eaf960b
3 files changed
+97 -1

No files matched your search

+15 -1
View File
@@ -93,6 +93,7 @@ import { externalSqlFileOpenErrorMessage, externalSqlEditorMaxBytes, isSqlFilePa
import type { ConnectionConfig, DatabaseType, ObjectBrowserFilter, ObjectSourceKind, QueryTab, TabOutputView, TreeNode } from "@/types/database";
import type { PluginCenterFocus } from "@/lib/plugins/pluginCenterNavigation";
import { parsePluginInstallDeepLink } from "@/lib/plugins/pluginInstallDeepLink";
import { createFrontendPluginRegistry } from "@/lib/plugins/frontendPlugin";
import { parseConnectionDeepLink, parseConnectionDeepLinkUpdate, type ConnectionDeepLinkDraft, type ConnectionDeepLinkUpdate } from "@/lib/connection/connectionDeepLink";
import { resolveConnectionDeepLinkUpdate } from "@/lib/connection/connectionDeepLinkUpdate";
import { parseAiConfigDeepLink, type AiConfigDeepLinkDraft } from "@/lib/ai/aiConfigDeepLink";
@@ -208,7 +209,7 @@ type AiAssistantHandle = {
type AuxiliarySearchSurface = "ai" | "history" | "sqlLibrary" | null;
const { t } = useI18n();
const { t, locale: appLocale } = useI18n();
const connectionStore = useConnectionStore();
const queryStore = useQueryStore();
const settingsStore = useSettingsStore();
@@ -216,6 +217,19 @@ const { active: appBackgroundActive, backgroundObjectUrl: appBackgroundObjectUrl
const { uiFontFamilyPreview } = useUiFontFamilyPreview();
const savedSqlStore = useSavedSqlStore();
const promptTemplateStore = usePromptTemplateStore();
let pluginTitleLocaleGeneration = 0;
watch(appLocale, async (locale) => {
const generation = ++pluginTitleLocaleGeneration;
try {
const registry = createFrontendPluginRegistry(await api.listPlugins(), locale);
if (generation !== pluginTitleLocaleGeneration) return;
queryStore.localizePluginTabTitles((pluginId, contributionId, surface) =>
surface === "filesystem" ? registry.listFilesystemProviders().find((entry) => entry.plugin.manifest.id === pluginId && entry.contribution.id === contributionId)?.contribution.label : registry.findUiContribution(pluginId, contributionId)?.contribution.label,
);
} catch (error) {
console.warn("Failed to refresh localized plugin tab titles", error);
}
});
const recentConnectionIds = ref<readonly string[]>(parseRecentConnectionIds(safeLocalStorageGet(RECENT_CONNECTION_IDS_STORAGE_KEY)));
connectionStore.setBeforeConnectHandler(async (config) => {
const jdbcxRuntime = await ensureJdbcxRuntimeDrivers(config, api);