/**
* 国际化文案获取工具函数
* 参考 AmountSummary 组件的实现方式,使用 useEngineContext 获取语言设置
*
* @example
* ```typescript
* import { useGetText } from './utils';
* import locales from './locales';
*
* const MyComponent = () => {
* const { getText, getTextFunc } = useGetText(locales);
*
* // 获取字符串文案
* const title = getText('component.title', 'Default Title');
*
* // 获取函数类型文案
* const formatFunc = getTextFunc('component.format');
* const formattedText = typeof formatFunc === 'function'
* ? formatFunc(arg1, arg2)
* : 'Default Text';
*
* return
{title}
;
* };
* ```
*/
export declare type SupportedLanguage = 'en' | 'zh-CN' | 'zh-HK' | 'ja' | 'pt';
export interface LocalesObject {
[key: string]: {
[key: string]: string | ((...args: any[]) => string);
};
}
export interface GetTextFunctions {
getText: (key: string, fallback?: string) => string;
getTextFunc: (key: string) => any;
getCurrentLanguage: () => string;
}
/**
* 使用 useEngineContext 创建本地化文案获取函数的 Hook
* @param locales - 本地化文案对象
* @returns getText 和 getTextFunc 函数
*/
export declare const useGetText: (locales: LocalesObject) => GetTextFunctions;
/**
* 创建本地化文案获取函数(非 Hook 版本,保持向后兼容)
* @param locales - 本地化文案对象
* @returns getText 和 getTextFunc 函数
* @deprecated 推荐使用 useGetText Hook 版本
*/
export declare const createGetText: (locales: LocalesObject) => GetTextFunctions;
/**
* 默认导出:直接创建一个通用的 getText 函数工厂
*/
export default createGetText;