translated electron menu

This commit is contained in:
SPRINX0\prochazka
2025-11-18 12:29:48 +01:00
parent d80c368ccb
commit f047ec787a
13 changed files with 70 additions and 42 deletions

View File

@@ -83,10 +83,27 @@ export function _t(key: string, options: TranslateOptions): string {
return compliledTranslation(values ?? {});
}
export function __t(key: string, options: TranslateOptions): () => string {
return () => _t(key, options);
export type DefferedTranslationResult = {
_transKey: string;
_transOptions: TranslateOptions;
};
export function __t(key: string, options: TranslateOptions): DefferedTranslationResult {
return {
_transKey: key,
_transOptions: options,
};
}
export function _val<T>(x: T | (() => T)): T {
return typeof x === 'function' ? (x as () => T)() : x;
export function _tval(x: string | DefferedTranslationResult): string {
if (typeof x === 'string') return x;
if (typeof x?._transKey === 'string') {
return _t(x._transKey, x._transOptions);
}
}
export function isDefferedTranslationResult(
x: string | DefferedTranslationResult
): x is DefferedTranslationResult {
return typeof x !== 'string' && typeof x?._transKey === 'string';
}