@discord/intl

中文文档
0.33.3发布于 2026/10/31MITTypeScriptCommonJS构建来源已验证近 30 天下载 18.3万

在 React 项目中管理消息和翻译的客户端运行时间.

中文使用文档

@discord/intl

重新定义国际化支持,由Discord创建,管理跨越多项目,多编程语言,多客户端平台的上百万条信息. 不和-intl支持将ICU MessageFormat语法与Markdown合并的扩展消息格式,使编写内容丰富,分层化的消息尽可能清晰而简洁.

这个项目的诞生是因为需要更灵活地进行翻译,希望拥有颗粒的所有权,以及需要重新设计,以跟上现代版本的翻译 intl-messageformat 还有其他能为系统提供动力的人.

使用量

你最可能只需要知道如何使用 defineMessages 用于编写新字符串和字符串模块。 一个消息 定义文件 必须 有扩展名 .messages.js,以及 必须 有默认的调用导出 defineMessages 内线,像这样:

// Import the defineMessages magic function from the package.
import { defineMessages } from '@discord/intl';

/**
 * Meta information about the strings contained in this file. Each string will
 * be tagged with this information by default, and it will be sent along to
 * translators to help provide context, categorization, and some special
 * features like hiding "secret" strings that shouldn't be bundled until a
 * specific release date.
 *
 * Future additions would be able to specify visual context for each string
 * (e.g. a screenshot image where the string is used) and more.
 */
export const meta = {
  project: 'custom-status',
  secret: true,
  translate: true,
};

/**
 * Messages are "defined" by creating a default export with `defineMessages`.
 * This function provides the typeguards for the shape of each message, and
 * ensures a consistent format for the external tooling to rely on when finding
 * all messages in the codebase.
 *
 * This _must_ be defined inline as a default export, and will be transformed
 * by bundlers both in development and production builds.
 */
export default defineMessages({
  HELLO_WORLD: {
    defaultMessage: 'Hello, world!',
    description: 'The standard greeting for new computers.',
  },
});

发展

这个项目与 intl-cli数字 :

# Compile the TypeScript source to distributable JavaScript once
pnpm intl-cli runtime build
# For development, run in watch mode to compile changes on the fly
pnpm intl-cli rt watch

版本与发布记录

@discord/intl 共发布 163 个版本,首次发布于 2024/08/07;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.33.3latest2026/10/3112 天前
0.33.22026/10/2320 天前
0.33.12026/10/061 个月前
0.32.02026/09/032 个月前
0.31.02026/08/202 个月前
0.30.02026/08/142 个月前

其他发布通道:canary → 0.28.0-canary.eb67948。

关于 @discord/intl 的常见问题

@discord/intl 是什么?

在 React 项目中管理消息和翻译的客户端运行时间.

如何安装 @discord/intl?

在项目目录运行 npm install @discord/intl,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(> 16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@discord/intl 支持 TypeScript 吗?

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

@discord/intl 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@discord/intl 可以商用吗?

@discord/intl 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@discord/intl 的下载量有多少?

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

@discord/intl 还在维护吗?

最新版本 0.33.3 发布于 2026/10/31(12 天前);至今共发布 163 个版本,其中过去 12 个月发布了 18 个;首次发布于 2024/08/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。