mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 20:06:00 +00:00
translated electron menu
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user