@enact/i18n

中文文档
5.6.0发布于 2026/09/02Apache-2.0TypeScriptCommonJS近 30 天下载 4.3万

Internationalization support for Enact using iLib

原始使用文档
文档目录4 节
  1. Usage
  2. Install
  3. Acknowledgments
  4. Copyright and License Information

@enact/i18n npm (scoped)

Internationalization library based on iLib.

@enact/i18n provides a decorator that can be used to wrap a root component in a React (or Enact) application. This decorator provides a context to child components that can be used to determine locale text directionality and to update the current locale.

Usage

import {I18nContextDecorator, I18nDecorator} from '@enact/i18n/I18nDecorator';

const MyComponent = I18nContextDecorator(
    {rtlProp: 'rtl'},
    (props) => (
        <div>{props.rtl ? 'right to left' : 'left to right'}</div>
    )
);

const MyApp = () => (
    <div>
        <MyComponent />
    </div>
);

const MyI18nApp = I18nDecorator(MyApp);

export default MyI18nApp;

Note: The @enact/i18n module will attempt to determine the locale automatically. Pass a locale prop ("en-US" for example) to this component where it is rendered to test.

Install

npm install --save @enact/i18n

Acknowledgments

This module is built upon the iLib library.

Unless otherwise specified, all content, including all source code files and documentation files in this repository are:

Copyright (c) 2016-2024 LG Electronics

Unless otherwise specified or set forth in the NOTICE file, all content, including all source code files and documentation files in this repository are: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this content except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This work is based on the Apache-2.0 licensed iLib from JEDLSoft.

版本与发布记录

@enact/i18n 共发布 241 个版本,首次发布于 2016/10/20;过去 12 个月发布了 9 个版本。

版本发布日期距今
5.6.0latest2026/09/022 个月前
5.5.22026/07/084 个月前
5.5.12026/06/015 个月前
5.4.42026/05/225 个月前
5.5.02026/05/086 个月前
5.4.32026/02/268 个月前

其他发布通道:agate → 2.2.0-alpha.1,experimental-latest → 3.4.9-experimental-7,mr-3.2 → 3.2.7,production → 4.0.13,latest-4.5 → 4.5.6,latest-4.0 → 4.0.15。

关于 @enact/i18n 的常见问题

@enact/i18n 是什么?

Internationalization support for Enact using iLib

如何安装 @enact/i18n?

在项目目录运行 npm install @enact/i18n,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ilib(^14.21.0 || ^14.21.0-webos1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@enact/i18n 支持 TypeScript 吗?

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

@enact/i18n 支持 ESM 还是 CommonJS?

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

@enact/i18n 可以商用吗?

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

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

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

@enact/i18n 还在维护吗?

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