Add full shell, replaceable Omics adapter and bilingual interaction
Implement approved specification #32 and tickets #33-#37. Keep host authentication server-verified and pin session interaction language. Compile scoped base selectors for browser compatibility and retain full gutters during CSS pruning.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { TranslationParams } from "../../i18n";
|
||||
|
||||
/** Keep IDs and parameters in state so open results follow later locale changes. */
|
||||
export type AdminMessage = string | {
|
||||
message: string;
|
||||
params?: Readonly<Record<string, string | number | { message: string }>>;
|
||||
};
|
||||
|
||||
export function adminMessage(message: string, params?: Exclude<AdminMessage, string>["params"]): AdminMessage {
|
||||
return { message, params };
|
||||
}
|
||||
|
||||
/** Local API diagnostics retain their code; translate only the known message body. */
|
||||
export function renderAdminDiagnostic(t: (message: string) => string, diagnostic: string): string {
|
||||
const match = /^([a-z][a-z_]+): (.+)$/.exec(diagnostic);
|
||||
return match ? `${match[1]}: ${t(match[2])}` : t(diagnostic);
|
||||
}
|
||||
|
||||
export function renderAdminMessage(
|
||||
t: (message: string, params?: TranslationParams) => string,
|
||||
value: AdminMessage,
|
||||
): string {
|
||||
if (typeof value === "string") return t(value);
|
||||
const params = value.params && Object.fromEntries(Object.entries(value.params).map(([key, param]) =>
|
||||
[key, typeof param === "object" ? t(param.message) : param],
|
||||
));
|
||||
return t(value.message, params);
|
||||
}
|
||||
Reference in New Issue
Block a user