ja-providers-strings-quality.test.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import fs from "node:fs";
  2. import path from "node:path";
  3. import { describe, expect, test } from "vitest";
  4. const readJson = (relPath: string) => {
  5. const filePath = path.join(process.cwd(), relPath);
  6. const text = fs.readFileSync(filePath, "utf8");
  7. return JSON.parse(text) as Record<string, string>;
  8. };
  9. const hasKana = /[ぁ-んァ-ン]/;
  10. describe("messages/ja/settings/providers/strings.json", () => {
  11. test("does not contain placeholder markers or fullwidth parentheses", () => {
  12. const ja = readJson("messages/ja/settings/providers/strings.json");
  13. for (const value of Object.values(ja)) {
  14. expect(value).not.toContain("[JA]");
  15. expect(value).not.toContain("(繁)");
  16. expect(value).not.toContain("(TW)");
  17. expect(value).not.toContain("(TW)");
  18. expect(value).not.toContain("(");
  19. expect(value).not.toContain(")");
  20. }
  21. });
  22. test("key UI strings are translated to Japanese", () => {
  23. const ja = readJson("messages/ja/settings/providers/strings.json");
  24. const keys = [
  25. "keyLoading",
  26. "noProviders",
  27. "noProvidersDesc",
  28. "official",
  29. "resetCircuit",
  30. "resetCircuitDesc",
  31. "resetCircuitFailed",
  32. "searchNoResults",
  33. "searchResults",
  34. "todayUsage",
  35. "toggleFailed",
  36. "toggleSuccess",
  37. "toggleSuccessDesc",
  38. "updateFailed",
  39. "viewKey",
  40. "viewKeyDesc",
  41. ] as const;
  42. for (const key of keys) {
  43. expect(ja[key]).toMatch(hasKana);
  44. }
  45. });
  46. });