Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.7 KB
Raw Blame
import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { english, localizeManifest, translate } from "../ui/i18n.js";

test("shell labels and diagnostics translate without altering arbitrary business data", async () => {
  for (const file of ["App.vue", "DebugPanel.vue"]) {
    const source = await readFile(new URL(`../ui/${file}`, import.meta.url), "utf8");
    for (const match of source.matchAll(/\bt\('([^']+)'/g)) {
      assert.ok(english[match[1]], `Missing English label: ${match[1]}`);
    }
  }
  assert.equal(translate("en", "RPC 完成"), "RPC completed");
  assert.equal(translate("zh-CN", "RPC 完成"), "RPC 完成");
  assert.equal(translate("en", "自定义连接"), "自定义连接");
  assert.match(translate("en", "删除连接“{name}”?其页面将关闭,未保存修改会丢失。", { name: "My DB" }), /My DB/);
});

test("manifest localization switches from original labels and preserves defaults", () => {
  const source = {
    name: "Example",
    contributions: [{ id: "main", label: "Page", fields: [{ key: "mode", label: "Mode", default: "one", options: [{ value: "one", label: "One" }] }] }],
    localizations: { "zh-CN": { name: "示例", contributions: { main: { label: "页面", fields: { mode: { label: "模式", options: { one: "一" } } } } } } },
  };
  const chinese = localizeManifest(source, "zh-CN");
  assert.equal(chinese.name, "示例");
  assert.equal(chinese.contributions[0].fields[0].options[0].label, "一");
  assert.equal(chinese.contributions[0].fields[0].default, "one");
  assert.equal(localizeManifest(source, "en").contributions[0].label, "Page");
  assert.equal(source.name, "Example");
});