I18nAPI

interface I18nAPI(source)

管理 i18n 服务和 i18n 自动翻译服务的 API。

AutoTweaker 会合并设置项描述和 i18n 条目。

AutoTweaker 会在后台对已注册的 i18n 条目进行自动翻译。

如果翻译模型未设置,翻译将不会进行。

See also

Functions

Link copied to clipboard
abstract fun getAll(): I18nEntries

获取所有 i18n 条目以及所有语言的文本,包括自动翻译后的文本。

Link copied to clipboard
abstract fun getDefault(id: String): Localizations?

获取某个 id 硬编码在声明中的 i18n 文案。

Link copied to clipboard
abstract fun getLanguage(): Locale

获取程序使用的语言,请不要使用 Locale.getDefault,通过此 api 获取到的语言可能经过用户配置。

Link copied to clipboard
abstract fun getString(id: String): String

通过 id 获取国际化的文本,通常用于获取设置项的描述。

Link copied to clipboard
abstract fun getTranslationModel(): UUID?

获取用于 i18n 翻译的大模型,模型可能无效,请自行确认。

Link copied to clipboard
abstract fun getTranslationStatus(): StateFlow<TranslationStatus>

获取自动翻译的实时状态。

Link copied to clipboard
abstract fun set(id: String, text: String, languageCode: Locale)

更新一个 i18n 条目某个语言的文本,或添加一个语言的文本。

Link copied to clipboard
abstract fun setLanguage(locale: Locale)

设置程序在国际化等场景下使用的语言。

Link copied to clipboard
abstract suspend fun setTranslationModel(modelId: UUID?)

设置用于 i18n 自动翻译的大模型,请自行确认模型有效。

Link copied to clipboard
abstract fun startTranslation(): Boolean

开始翻译所有 i18n 条目,方法会启动后台协程并立即返回,不会挂起等待翻译完毕。