@authup/i18n

中文文档
1.0.0-beta.73发布于 2026/11/02Apache-2.0TypeScriptES Module近 30 天下载 1987

Authup's translation catalogs in English, German, French and Spanish, ready for an ilingo store.

原始使用文档
文档目录9 节
  1. Why @authup/i18n?
  2. Installation
  3. Usage
  4. Load the catalogs
  5. Pick singular or plural
  6. Namespaces
  7. API
  8. Notes
  9. License

Authup logo

@authup/i18n

Authup's translation catalogs in English, German, French and Spanish, ready for an ilingo store.
The labels, error messages and mail copy the consoles and the server use, without a framework attached.

npm version CI License: Apache-2.0

Installation · Usage · API · Documentation


Why @authup/i18n?

An application that embeds Authup's UI components, renders Authup's error codes or names its permissions needs the same words Authup uses, in the same languages. This package is those words as plain data: an ilingo catalog tree you load into a store, plus the locale registry and the key enums.

ConcernWithout itWith it
Error messagesA message table for every ErrorCode you might receiveauthupError namespace, keyed by the ErrorCode values of @authup/errors
Permission and scope namesShowing raw identifiers such as user_updateauthupPermission, authupScope and authupPolicy give a display name per built-in identifier
LocalesA list of supported languages kept in step by handLOCALES, isLocale and matchLocale over the four authored locales
Key driftA key missing in one language shows up at runtimeEvery catalog is typed against its key enum, and a parity test checks all four locales

Installation

npm install @authup/i18n ilingo

ESM only. Node.js >=26.0.0. ilingo is a dependency of this package; install it yourself as well when your code builds the Ilingo instance. @ebec/core and validup are optional peers: they matter only for the typed IssueDataByCode augmentation this package declares.

Usage

Load the catalogs

import {
    CATALOGS,
    DEFAULT_LOCALE,
    TranslatorTranslationMailKey,
    TranslatorTranslationNamespace,
    matchLocale,
} from '@authup/i18n';
import { ErrorCode } from '@authup/errors';
import { Ilingo, MemoryStore } from 'ilingo';

const ilingo = new Ilingo({
    store: new MemoryStore({ data: CATALOGS }),
    locale: DEFAULT_LOCALE,
});

const locale = matchLocale('de-DE') ?? DEFAULT_LOCALE; // 'de'

await ilingo.get({
    namespace: TranslatorTranslationNamespace.ERROR,
    key: ErrorCode.ENTITY_NOT_FOUND,
    locale,
});

await ilingo.get({
    namespace: TranslatorTranslationNamespace.MAIL,
    key: TranslatorTranslationMailKey.PASSWORD_RESET_EXPIRY,
    data: { minutes: 30 },
}); // 'The code expires in 30 minutes.'
  • CATALOGS is an ilingo CatalogNode (locale, then namespace, then translations), so MemoryStore({ data: CATALOGS }) takes it as is and getSync works too.
  • matchLocale lowercases the tag, keeps the primary subtag and returns it when it is an authored locale, else undefined.
  • Values may carry {{name}} placeholders, filled from data.

Pick singular or plural

import { TranslatorTranslationEntityKey, TranslatorTranslationNamespace } from '@authup/i18n';
import type { Ilingo } from 'ilingo';

declare const ilingo: Ilingo;

await ilingo.get({
    namespace: TranslatorTranslationNamespace.ENTITY,
    key: TranslatorTranslationEntityKey.USER,
    count: 1,
}); // 'User'

Entity nouns are ilingo plural nodes: count: 1 selects the singular, any other count the plural.

Namespaces

Enum memberNamespaceKeys
ENTITYauthupEntityTranslatorTranslationEntityKey, plural nouns
FIELDauthupFieldTranslatorTranslationFieldKey
ACTIONauthupActionTranslatorTranslationActionKey
COMMONauthupCommonTranslatorTranslationCommonKey
CLIENTauthupClientTranslatorTranslationClientKey
APPauthupAppTranslatorTranslationAppKey
ERRORauthupErrorErrorCode from @authup/errors
MAILauthupMailTranslatorTranslationMailKey, transactional mail copy
PERMISSIONauthupPermissionPermissionName from @authup/core-kit
SCOPEauthupScopeScopeName from @authup/core-kit
POLICYauthupPolicySystemPolicyName from @authup/access
VUECSvuecsTranslatorTranslationVuecsKey, overrides for @vuecs/* components

API

ExportKindPurpose
CATALOGSconstEvery authored locale and namespace, as an ilingo catalog node
TranslatorTranslation<Namespace><Language>constOne namespace of one locale, e.g. TranslatorTranslationErrorGerman
TranslatorTranslationNamespaceenumThe namespace names above
TranslatorTranslation<Namespace>KeyenumThe key set of each authup-owned namespace
LOCALES, LOCALE_CODES, DEFAULT_LOCALEconsten, de, fr, es with their native names; the default is en
isLocale, matchLocalefunctionNarrow a string or a BCP-47 tag onto an authored locale
LocaleCode, LocaleDescriptor, NamespaceTranslations, AuthupErrorData, SystemPolicyNameValuetypeLocale, catalog and error-data types

Notes

  • Policy names contain dots. system.default is a path to ilingo, so escape the dots when you look one up: key: 'system\\.default'.
  • The namespaces are prefixed with authup so they cannot collide with a host application's own catalogs. Only vuecs is not, because it overrides the @vuecs/* components' own namespace.
  • Every catalog is loaded eagerly. All four locales are in CATALOGS; there is no lazy loading per locale yet.

License

Made with 💚

Published under the Apache 2.0 License.

版本与发布记录

@authup/i18n 共发布 29 个版本,首次发布于 2026/06/09;过去 12 个月发布了 29 个版本。

版本发布日期距今
1.0.0-beta.73latest2026/11/025 天前
1.0.0-beta.722026/10/2711 天前
1.0.0-beta.712026/10/2018 天前
1.0.0-beta.702026/10/1919 天前
1.0.0-beta.692026/10/1424 天前
1.0.0-beta.682026/09/251 个月前

关于 @authup/i18n 的常见问题

@authup/i18n 是什么?

Authup's translation catalogs in English, German, French and Spanish, ready for an ilingo store.

如何安装 @authup/i18n?

在项目目录运行 npm install @authup/i18n,或使用 pnpm add / yarn add / bun add。

@authup/i18n 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@authup/i18n 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@authup/i18n 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@authup/i18n 可以商用吗?

@authup/i18n 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@authup/i18n 的下载量有多少?

根据 npm 官方下载统计,@authup/i18n 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,987 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@authup/i18n 还在维护吗?

最新版本 1.0.0-beta.73 发布于 2026/11/02(5 天前);至今共发布 29 个版本,其中过去 12 个月发布了 29 个;首次发布于 2026/06/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。