@techui/locales
v0.2.0
Published
TechUI locales, Used to support the multi-language function of Techui component library.
Readme
@techui/locales
English
Introduction
@techui/locales is the locale resource package for TechUI. It provides the built-in language data used by TechUI components and exposes runtime APIs for on-demand loading and dynamic extension.
Built-In Loading
Use the default localeLoader entry when a locale should be loaded through the unified loader:
import localeLoader from "@techui/locales"
await localeLoader.ensure("en")Shortcut locale entries are also available:
import "@techui/locales/zh-CN"
import "@techui/locales/zh-TW"
import "@techui/locales/en"Runtime Locale Registration
External packages and host projects can register extra locale modules at any time:
import { registerLocaleModule } from "@techui/locales"
registerLocaleModule("myWidget", {
"zh-CN": {
myWidget: { title: "标题" }
},
en: {
myWidget: { title: "Title" }
}
})Registration is dynamic. If the current app has already initialized the same language, the Provider refreshes its reactive locale state immediately after the module is registered.
Duplicate detection uses language + namespace. Re-registering the same namespace overwrites the previous module and prints a warning by default. Pass { force: true } when the overwrite is intentional and should not warn:
registerLocaleModule("myWidget", locales, { force: true })Locale modules are deep-merged into the base language package. The merge only adds or overwrites keys; it does not delete existing keys.
Supported Languages
- Simplified Chinese (
zh-CN) - Traditional Chinese (
zh-TW) - English (
en)
Package Information
- Version source: See
package.json; the package version follows the confirmed TechUI release matrix. - Author: [email protected] (WeChat: jay1986cn)
- China Site: https://techui.cn/
- Global Site: https://techui.net/
- Keywords: @techui, techui, ayin, locales, i18n
中文
简介
@techui/locales 是 TechUI 的多语言资源包。它提供 TechUI 组件内部使用的内置语言数据,并暴露按需加载和运行时动态扩展能力。
内置加载
需要通过统一入口加载语言资源时,使用默认导出的 localeLoader:
import localeLoader from "@techui/locales"
await localeLoader.ensure("en")也可以直接使用语言子路径注册指定语言:
import "@techui/locales/zh-CN"
import "@techui/locales/zh-TW"
import "@techui/locales/en"运行时语言包注册
外挂组件包和宿主工程可以在任意时机注册额外语言模块:
import { registerLocaleModule } from "@techui/locales"
registerLocaleModule("myWidget", {
"zh-CN": {
myWidget: { title: "标题" }
},
en: {
myWidget: { title: "Title" }
}
})注册是动态的。如果当前应用已经初始化了同一语言,模块注册后 Provider 会立即刷新响应式语言状态。
重复判断使用 语言 + namespace。重复注册同一 namespace 时会覆盖旧模块,并默认输出告警;如果是预期覆盖,可以传入 { force: true } 关闭告警:
registerLocaleModule("myWidget", locales, { force: true })外部语言模块会深合并到基础语言包中。合并只负责新增或覆盖字段,不负责删除旧字段。
支持的语言
- 简体中文 (
zh-CN) - 繁体中文 (
zh-TW) - 英文 (
en)
包信息
- 版本来源:以
package.json为准,包版本跟随确认后的 TechUI 发布矩阵。 - 作者: [email protected] (微信: jay1986cn)
- 中国站: https://techui.cn/
- 全球站: https://techui.net/
- 关键词: @techui, techui, ayin, locales, i18n
