Admin: tlumaczenia akcji audytu w logach (uzupelnione pl/en logs.json o 8 brakujacych akcji planu/konta + ACTION_KEYS o te akcje, dodane etykiety surowych kluczy szczegolow, nowy test logs-i18n pilnuje pokrycia i parzystosci pl/en)
This commit is contained in:
@@ -51,7 +51,20 @@
|
||||
"equipmentId": "equipment",
|
||||
"planTitle": "plan",
|
||||
"exercises": "exercises",
|
||||
"sets": "sets"
|
||||
"sets": "sets",
|
||||
"templateId": "template",
|
||||
"sourcePlanId": "source plan",
|
||||
"movedDays": "moved days",
|
||||
"byAdmin": "by admin",
|
||||
"changeNote": "change note",
|
||||
"count": "count",
|
||||
"side": "side",
|
||||
"source": "source",
|
||||
"typeId": "circumference type",
|
||||
"instanceId": "equipment instance",
|
||||
"photoId": "photo",
|
||||
"swappedWith": "swapped with",
|
||||
"type": "claim type"
|
||||
},
|
||||
"actions": {
|
||||
"user": {
|
||||
@@ -62,6 +75,7 @@
|
||||
"updated": "Account updated (admin)",
|
||||
"status": { "changed": "Account status changed" },
|
||||
"admin": { "changed": "Admin role changed" },
|
||||
"password": { "changed": "Password changed" },
|
||||
"deleted": "Account deleted"
|
||||
},
|
||||
"profile": { "updated": "Profile updated" },
|
||||
@@ -70,13 +84,24 @@
|
||||
"plan": {
|
||||
"created": "Plan created",
|
||||
"updated": "Plan updated",
|
||||
"gym": { "updated": "Plan gym changed" },
|
||||
"deleted": "Plan deleted",
|
||||
"activated": "Plan activated",
|
||||
"suspended": "Plan suspended",
|
||||
"resumed": "Plan resumed after suspension",
|
||||
"abandoned": "Plan abandoned",
|
||||
"completed": "Plan completed",
|
||||
"reopened": "Plan reopened",
|
||||
"shared": "Plan shared",
|
||||
"unshared": "Plan sharing revoked"
|
||||
"unshared": "Plan sharing revoked",
|
||||
"day": {
|
||||
"moved": "Plan day moved",
|
||||
"skip": { "accepted": "Skipped day accepted" }
|
||||
},
|
||||
"template": {
|
||||
"saved": "Template saved",
|
||||
"cloned": "Plan cloned from template"
|
||||
}
|
||||
},
|
||||
"session": {
|
||||
"started": "Session started",
|
||||
|
||||
@@ -51,7 +51,20 @@
|
||||
"equipmentId": "sprzęt",
|
||||
"planTitle": "plan",
|
||||
"exercises": "ćwiczenia",
|
||||
"sets": "serie"
|
||||
"sets": "serie",
|
||||
"templateId": "szablon",
|
||||
"sourcePlanId": "plan źródłowy",
|
||||
"movedDays": "przesunięte dni",
|
||||
"byAdmin": "przez administratora",
|
||||
"changeNote": "notatka zmiany",
|
||||
"count": "liczba",
|
||||
"side": "strona",
|
||||
"source": "źródło",
|
||||
"typeId": "rodzaj obwodu",
|
||||
"instanceId": "instancja wyposażenia",
|
||||
"photoId": "zdjęcie",
|
||||
"swappedWith": "zamieniono z",
|
||||
"type": "rodzaj wniosku"
|
||||
},
|
||||
"actions": {
|
||||
"user": {
|
||||
@@ -62,6 +75,7 @@
|
||||
"updated": "Konto zaktualizowane (admin)",
|
||||
"status": { "changed": "Zmiana statusu konta" },
|
||||
"admin": { "changed": "Zmiana roli administratora" },
|
||||
"password": { "changed": "Zmiana hasła" },
|
||||
"deleted": "Konto usunięte"
|
||||
},
|
||||
"profile": { "updated": "Zmiana profilu" },
|
||||
@@ -70,13 +84,24 @@
|
||||
"plan": {
|
||||
"created": "Plan utworzony",
|
||||
"updated": "Plan zaktualizowany",
|
||||
"gym": { "updated": "Siłownia planu zmieniona" },
|
||||
"deleted": "Plan usunięty",
|
||||
"activated": "Plan aktywowany",
|
||||
"suspended": "Plan zawieszony",
|
||||
"resumed": "Plan wznowiony po zawieszeniu",
|
||||
"abandoned": "Plan porzucony",
|
||||
"completed": "Plan ukończony",
|
||||
"reopened": "Plan wznowiony",
|
||||
"shared": "Plan udostępniony",
|
||||
"unshared": "Udostępnienie planu cofnięte"
|
||||
"unshared": "Udostępnienie planu cofnięte",
|
||||
"day": {
|
||||
"moved": "Dzień planu przesunięty",
|
||||
"skip": { "accepted": "Pominięcie dnia zaakceptowane" }
|
||||
},
|
||||
"template": {
|
||||
"saved": "Szablon zapisany",
|
||||
"cloned": "Plan skopiowany z szablonu"
|
||||
}
|
||||
},
|
||||
"session": {
|
||||
"started": "Sesja rozpoczęta",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const ACTION_KEYS = [
|
||||
'user.updated',
|
||||
'user.status.changed',
|
||||
'user.admin.changed',
|
||||
'user.password.changed',
|
||||
'user.deleted',
|
||||
'profile.updated',
|
||||
'weight.added',
|
||||
@@ -39,13 +40,20 @@ export const ACTION_KEYS = [
|
||||
'circumference.removed',
|
||||
'plan.created',
|
||||
'plan.updated',
|
||||
'plan.gym.updated',
|
||||
'plan.deleted',
|
||||
'plan.activated',
|
||||
'plan.suspended',
|
||||
'plan.resumed',
|
||||
'plan.abandoned',
|
||||
'plan.completed',
|
||||
'plan.reopened',
|
||||
'plan.shared',
|
||||
'plan.unshared',
|
||||
'plan.day.moved',
|
||||
'plan.day.skip.accepted',
|
||||
'plan.template.saved',
|
||||
'plan.template.cloned',
|
||||
'session.started',
|
||||
'session.completed',
|
||||
'session.abandoned',
|
||||
|
||||
68
admin/test/logs-i18n.test.ts
Normal file
68
admin/test/logs-i18n.test.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { ACTION_KEYS } from '../src/pages/Logs';
|
||||
|
||||
const LOCALES_DIR = path.join(__dirname, '..', 'src', 'i18n', 'locales');
|
||||
|
||||
type Json = Record<string, unknown>;
|
||||
|
||||
function load(locale: string, ns: string): Json {
|
||||
return JSON.parse(readFileSync(path.join(LOCALES_DIR, locale, `${ns}.json`), 'utf8')) as Json;
|
||||
}
|
||||
|
||||
function flatKeys(node: Json, prefix = ''): string[] {
|
||||
return Object.entries(node).flatMap(([key, value]) => {
|
||||
const full = prefix ? `${prefix}.${key}` : key;
|
||||
if (value && typeof value === 'object') return flatKeys(value as Json, full);
|
||||
return [full];
|
||||
});
|
||||
}
|
||||
|
||||
function actionKeys(locale: string): Set<string> {
|
||||
return new Set(flatKeys(load(locale, 'logs').actions as Json));
|
||||
}
|
||||
|
||||
describe('logs: pokrycie tłumaczeń akcji audytu', () => {
|
||||
it('każda akcja z filtra ma tłumaczenie w pl i en', () => {
|
||||
const pl = actionKeys('pl');
|
||||
const en = actionKeys('en');
|
||||
const missingPl = ACTION_KEYS.filter((a) => !pl.has(a));
|
||||
const missingEn = ACTION_KEYS.filter((a) => !en.has(a));
|
||||
expect(missingPl).toEqual([]);
|
||||
expect(missingEn).toEqual([]);
|
||||
});
|
||||
|
||||
it('klucze akcji planu i konta nie wypadają z tłumaczeń', () => {
|
||||
for (const locale of ['pl', 'en']) {
|
||||
const keys = actionKeys(locale);
|
||||
for (const action of [
|
||||
'plan.template.cloned',
|
||||
'plan.template.saved',
|
||||
'plan.suspended',
|
||||
'plan.resumed',
|
||||
'plan.gym.updated',
|
||||
'plan.day.moved',
|
||||
'plan.day.skip.accepted',
|
||||
'user.password.changed',
|
||||
]) {
|
||||
expect(keys.has(action), `${locale}: brak tłumaczenia ${action}`).toBe(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('pl i en mają identyczne klucze w namespace logs', () => {
|
||||
expect(flatKeys(load('en', 'logs')).sort()).toEqual(flatKeys(load('pl', 'logs')).sort());
|
||||
});
|
||||
|
||||
it('żadne tłumaczenie nie jest puste', () => {
|
||||
for (const locale of ['pl', 'en']) {
|
||||
const raw = load(locale, 'logs');
|
||||
const empty = flatKeys(raw).filter((k) => {
|
||||
const value = k.split('.').reduce<unknown>((acc, part) => (acc as Json)[part], raw);
|
||||
return typeof value !== 'string' || value.trim() === '';
|
||||
});
|
||||
expect(empty).toEqual([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user