magner
Version:
Universal admin panel magnetic to any backend
37 lines (36 loc) • 1.38 kB
TypeScript
import { Ref } from 'vue';
import type { I18n } from 'vue-i18n';
import type { GlobalValues } from '../../global';
type TArgs = Parameters<GlobalValues['t']>;
/**
* Use this function in the configs and other non-reactive .ts files to get complete typings of i18n.
* Returns an object that should be passed to 'translateDataToString' function in the vue component
*/
export declare const translate: (key: TArgs[0], params?: TArgs[1]) => {
key: string | number;
params: Record<string, unknown> | null;
};
/** Use a string for single-language apps or a 'translate' function with translation key */
export type TranslateData = string | {
key: TArgs[0];
params: TArgs[1] | null;
};
export declare const customT: (data: TranslateData, t: (arg_1: TArgs[0], arg_2?: TArgs[1]) => string) => string;
type UseTranslate = () => {
t: I18n['global']['t'];
d: I18n['global']['d'];
n: I18n['global']['n'];
locale: Ref<I18n['global']['locale']>;
customT: (data: TranslateData) => string;
};
/**
* Function applies reactive i18n to the translate data. Use it in the Vue component's setup
* for the objects you've got from 'translate' function.
*/
export declare const useTranslate: UseTranslate;
/** An error supporting translations */
export declare class TranslateError extends Error {
name: string;
constructor(name: TranslateData);
}
export {};