import type { OnModuleInit } from '@nestjs/common'; import type { Handler, Request } from 'express'; import type { GraphQLError } from 'graphql'; import type { TFunction } from 'i18next'; /** * @description * 用于多语言翻译的I18资源 * * @docsCategory Translation */ export interface PickerTranslationResources { error: any; errorResult: any; message: any; } export interface I18nRequest extends Request { t: TFunction; } /** * 该服务负责在消息到达客户端之前翻译来自服务器的消息。 * `i18next-express-middleware`中间件检测客户端的首选语言 * `Accept-Language` Header 或 "lang" 查询参数,并添加语言特定的翻译函数到 Express request / response 对象。 * @docsCategory Translation */ export declare class I18nService implements OnModuleInit { /** * @internal * @param configService */ /** * @internal */ onModuleInit(): Promise>; /** * @internal */ handle(): Handler; /** * @description * 添加一个基于 json 的 I18n 翻译文件 * * @param langKey language key of the I18n translation file * @param filePath path to the I18n translation file */ addTranslationFile(langKey: string, filePath: string): void; /** * @description * 添加一个 I18n 转换 (key-value) 资源 * * @param langKey language key of the I18n translation file * @param resources key-value translations */ addTranslation(langKey: string, resources: PickerTranslationResources | any): void; /** * 如果是i18error的实例,则转换originalError。 * @internal */ translateError(req: I18nRequest, error: GraphQLError): GraphQLError; /** * 转换 ErrorResult 的消息 * @internal */ translateErrorResult(req: I18nRequest, error: any): void; }