chore: add test to check locale message keys consistency (#329)
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
"skipped": "スキップ"
|
"skipped": "スキップ"
|
||||||
},
|
},
|
||||||
"Priority": {
|
"Priority": {
|
||||||
"priority": "優先度",
|
|
||||||
"critical": "致",
|
"critical": "致",
|
||||||
"high": "高",
|
"high": "高",
|
||||||
"medium": "中",
|
"medium": "中",
|
||||||
@@ -136,6 +135,14 @@
|
|||||||
"current_password_incorrect": "現在のパスワードが正しくありません",
|
"current_password_incorrect": "現在のパスワードが正しくありません",
|
||||||
"update_error": "更新に失敗しました"
|
"update_error": "更新に失敗しました"
|
||||||
},
|
},
|
||||||
|
"Health": {
|
||||||
|
"health_check": "ヘルスチェック",
|
||||||
|
"status": "ステータス",
|
||||||
|
"ok": "正常",
|
||||||
|
"error": "エラー",
|
||||||
|
"api_server": "APIサーバー",
|
||||||
|
"unittcms_version": "UnitTCMS バージョン"
|
||||||
|
},
|
||||||
"Admin": {
|
"Admin": {
|
||||||
"user_management": "ユーザー管理",
|
"user_management": "ユーザー管理",
|
||||||
"avatar": "アバター",
|
"avatar": "アバター",
|
||||||
@@ -154,14 +161,6 @@
|
|||||||
"lost_admin_auth": "管理者権限を失いました",
|
"lost_admin_auth": "管理者権限を失いました",
|
||||||
"at_least": "最低1人以上の管理者が必要です。"
|
"at_least": "最低1人以上の管理者が必要です。"
|
||||||
},
|
},
|
||||||
"Health": {
|
|
||||||
"health_check": "ヘルスチェック",
|
|
||||||
"status": "ステータス",
|
|
||||||
"ok": "正常",
|
|
||||||
"error": "エラー",
|
|
||||||
"api_server": "APIサーバー",
|
|
||||||
"unittcms_version": "UnitTCMS バージョン"
|
|
||||||
},
|
|
||||||
"Projects": {
|
"Projects": {
|
||||||
"project_list": "プロジェクト一覧",
|
"project_list": "プロジェクト一覧",
|
||||||
"new_project": "新規プロジェクト",
|
"new_project": "新規プロジェクト",
|
||||||
@@ -314,8 +313,8 @@
|
|||||||
"refresh": "再読み込み",
|
"refresh": "再読み込み",
|
||||||
"id": "ID",
|
"id": "ID",
|
||||||
"title": "タイトル",
|
"title": "タイトル",
|
||||||
"description": "詳細",
|
|
||||||
"please_enter": "タイトルを入力してください",
|
"please_enter": "タイトルを入力してください",
|
||||||
|
"description": "詳細",
|
||||||
"priority": "優先度",
|
"priority": "優先度",
|
||||||
"status": "ステータス",
|
"status": "ステータス",
|
||||||
"actions": "アクション",
|
"actions": "アクション",
|
||||||
|
|||||||
33
frontend/messages/strings.test.ts
Normal file
33
frontend/messages/strings.test.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import en from './en.json';
|
||||||
|
import ja from './ja.json';
|
||||||
|
import ptBR from './pt-BR.json';
|
||||||
|
|
||||||
|
function getAllKeys(obj: unknown, prefix = ''): string[] {
|
||||||
|
if (typeof obj !== 'object' || obj === null) return [];
|
||||||
|
return Object.entries(obj as Record<string, unknown>).flatMap(([key, value]) => {
|
||||||
|
const fullKey = prefix ? `${prefix}.${key}` : key;
|
||||||
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||||
|
return getAllKeys(value, fullKey);
|
||||||
|
}
|
||||||
|
return [fullKey];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Locale message keys consistency', () => {
|
||||||
|
const locales = [
|
||||||
|
{ name: 'en', data: en },
|
||||||
|
{ name: 'ja', data: ja },
|
||||||
|
{ name: 'pt-BR', data: ptBR },
|
||||||
|
];
|
||||||
|
|
||||||
|
const base = locales[0];
|
||||||
|
const baseKeys = getAllKeys(base.data);
|
||||||
|
|
||||||
|
for (const locale of locales.slice(1)) {
|
||||||
|
it(`should have the same keys as ${base.name} in ${locale.name}`, () => {
|
||||||
|
const localeKeys = getAllKeys(locale.data);
|
||||||
|
expect(localeKeys).toEqual(baseKeys);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user