TranslationResult

@ai-i18n/vite 导入:

import type { TranslationResult } from '@ai-i18n/vite';

定义

type TranslationResult = Readonly<Record<string, string | null>>;

键必须与当前 TranslationBatch.locales 完全一致。 任意字符串(包括空字符串)都是有效译文;null 表示该目标语言仍缺译。Runtime 只对 null 或 缺失字段回退 source 文案。

const result: TranslationResult = {
  'en-US': 'Save',
  'ja-JP': null,
};

Translator 返回值中缺少语言键、包含额外键,或使用非字符串且非 null 的值时,Vite 会拒绝 该批结果。