import { setLanguage } from "@uxland/localization"; import { PrimariaApi } from "./api/api"; import { primariaShellId } from "./constants"; let shellLocaleManager; export const useLocalization = async (api: PrimariaApi) => { setLanguage("ca"); const localeManager = await api.createLocaleManager(locales); shellLocaleManager = localeManager; }; type LocaleKeys = T extends object ? { [K in keyof T]: `${K & string}` | (T[K] extends object ? `${K & string}.${LocaleKeys}` : never); }[keyof T] : never; export type ShellLocales = LocaleKeys<(typeof locales)[typeof defaultLang][typeof primariaShellId]>; export const translate = (path: ShellLocales) => { if (shellLocaleManager) return shellLocaleManager.translate(path); return path; }; export { shellLocaleManager }; const defaultLang = "ca"; export const locales = { ca: { [primariaShellId]: { title: "Estació de Treball Clínica", actions: { create: "Crear", toggleMenuClose: "Tancar menú", toggleMenuOpen: "Expandir menú", askExit: "Atenció, vols sortir igualment?", }, errors: { session: "Hi ha hagut un error amb la sessió. Siusplau, tanca i torna a obrir l'aplicació.", invalidPatient: "El pacient actual no és vàlid. Siusplau, tanca i torna a obrir l'aplicació.", exit: "Hi ha hagut un error en sortir de l'ETC", }, header: { workCenter: "Centre treball", role: "Tipus de profesional", speciality: "Àmbit treball", }, busyManager: { title: "Tasques pendents:", }, pdfManager: { uploaded: "Document disponible al visor de resultats", alreadyUploaded: "Ja s'ha carregat un document amb aquest nom", navButtonLabel: "Visor PDF", missingData: "Es necesita un document o URL per enviar al visor de resultats", duplicatedSource: "Només pots envar un document o URL a la vegada", tooltipMessage: "S'ha generat el PDF al visor", }, pdfVisor: { noPdfSelected: "No hi ha cap PDF seleccionat", }, importDataManager: { title: "Importar dades", actions: { cancel: "Cancel·lar", import: "Importar dades", }, }, }, }, };