@ices/react-locale
Version:
React components for locale
45 lines (44 loc) • 2.46 kB
TypeScript
import { LocaleResourceLoader } from './context';
import { MessageData, MessageDefinitions, TranslateFunction } from './message';
import { UseContextTransType, UseTransResponse, UseTransType, withDefinitionsContextHook, withDefinitionsHook } from './hooks';
import { TranslateProps, TranslateType, withDefinitionsComponent } from './Translate';
import { determineLocale } from './utils';
export { MessageDefinitions, TranslateFunction, TranslateProps, TranslateType, UseContextTransType, UseTransType, UseTransResponse, LocaleResourceLoader, determineLocale, withDefinitionsComponent, withDefinitionsContextHook, withDefinitionsHook, };
export { LocaleContext, LocaleProvider, addLoadErrorListener, addLoadStartListener, addLoadFinishListener, setLocale, setFallbackLocale, setDebugMessageFilter, getLocale, getFallbackLocale, subscribe, } from './context';
export { PluginFunction, PluginTranslate, MessageValue, MessageData } from './message';
export declare type AsyncLocaleResources = {
[P: string]: () => Promise<{
default: MessageData;
}>;
};
export declare type UseTranslatorResponse = {
useTrans: UseTransType;
useContextTrans: UseContextTransType;
Translate: TranslateType;
};
/**
* 获取以同步或异步方式加载的本地化资源文件的hook或组件。
* @param locales 可同步或异步加载的本地化资源。
*/
export declare function useTranslator(locales?: MessageDefinitions | AsyncLocaleResources | LocaleResourceLoader): UseTranslatorResponse;
/**************************************************************************
* API的实际导出是由构建插件@ices/locale-webpack-plugin根据语言定义文件自动生成。 \
* 下面导出的常量,仅为自动生成定义声明,请不要直接使用。 \
* 如果需要自己绑定语言模块,可使用 useTranslator 自行绑定。 \
*************************************************************************/
/**
* 类型组件内使用的转译组件。
*/
export declare const Trans: TranslateType;
/**
* 函数组件内使用的hook,可提供区域语言内容转译。
*/
export declare const useTrans: UseTransType;
/**
* 函数组件内使用的绑定至指定上下文组件的内容转译hook。
*/
export declare const useContextTrans: UseContextTransType;
/**
* 语言模块内的消息定义内容。
*/
export declare const definitions: MessageDefinitions;