feature: localization's first implmentation done. all frontend hardcoded text is now localized.

This commit is contained in:
2026-06-20 14:51:43 +03:30
parent 284fbd08aa
commit b2f4dfa4ca
52 changed files with 3306 additions and 1041 deletions

View File

@@ -1,17 +1,23 @@
import type { LinkedOrganizationOption, TreatmentCaseSendInfo } from '@/types/treatment';
export type CaseSendLabelT = (
key: 'sentToAt' | 'fallbackOrgName',
values?: { orgName: string; datetime: string },
) => string;
export function formatCaseSentLines(
sends: TreatmentCaseSendInfo[] | undefined,
fallback?: {
fallback: {
organizationIds: string[];
sentAt: string | null;
orgs?: LinkedOrganizationOption[];
},
} | undefined,
t: CaseSendLabelT,
): string[] {
if (sends?.length) {
return sends.map((s) => {
const at = new Date(s.sentAt).toLocaleString();
return `Sent to ${s.organizationName} at ${at}`;
return t('sentToAt', { orgName: s.organizationName, datetime: at });
});
}
@@ -19,8 +25,8 @@ export function formatCaseSentLines(
const at = new Date(fallback.sentAt).toLocaleString();
const nameById = new Map(fallback.orgs?.map((o) => [o.id, o.name]) ?? []);
return fallback.organizationIds.map((id) => {
const name = nameById.get(id) ?? 'organization';
return `Sent to ${name} at ${at}`;
const name = nameById.get(id) ?? t('fallbackOrgName');
return t('sentToAt', { orgName: name, datetime: at });
});
}
@@ -29,12 +35,13 @@ export function formatCaseSentLines(
export function formatCaseSentSummary(
sends: TreatmentCaseSendInfo[] | undefined,
fallback?: {
fallback: {
organizationIds: string[];
sentAt: string | null;
orgs?: LinkedOrganizationOption[];
},
} | undefined,
t: CaseSendLabelT,
): string | null {
const lines = formatCaseSentLines(sends, fallback);
const lines = formatCaseSentLines(sends, fallback, t);
return lines.length > 0 ? lines.join(' · ') : null;
}