@canva/app-i18n-kit

中文文档
1.3.0发布于 2026/07/28SEE LICENSE IN LICENSE.mdTypeScriptESM + CJS零依赖近 30 天下载 7万

Internationalization kit for Canva apps. Adapts react-intl and @formatjs/intl to work with the Canva Apps SDK localization process

原始使用文档
文档目录11 节
  1. Table of contents
  2. Introduction
  3. Within React components - Example usage
  4. Outside React components - Example usage
  5. Installation
  6. For React apps
  7. For non-React apps
  8. Usage
  9. Changelog
  10. Contributing
  11. License

@canva/app-i18n-kit

Internationalization kit for Canva apps. Adapts react-intl and @formatjs/intl to work with the Canva Apps SDK localization process

Table of contents

Introduction

The @canva/app-i18n-kit package provides utilities required to localize Canva apps. It supports:

  • Within React components - Using the AppI18nProvider component, FormattedMessage component and useIntl hook
  • Outside React components - Using the initIntl function

Within React components - Example usage

import { AppI18nProvider } from "@canva/app-i18n-kit";
import { FormattedMessage, useIntl } from "react-intl";

// Wrap your app at the root
function App() {
  return (
    <AppI18nProvider>
      <MyComponent />
    </AppI18nProvider>
  );
}

// Use hooks or components within the provider
function MyComponent() {
  const intl = useIntl();
  const placeholder = intl.formatMessage({
    defaultMessage: "Search...",
    description:
      "Placeholder text shown in the search input field before the user types",
  });

  return (
    <Box>
      <FormattedMessage
        defaultMessage="Welcome to my app"
        description="Heading displayed at the top of the app when it first loads"
      />
      <TextInput placeholder={placeholder} />
    </Box>
  );
}

Outside React components - Example usage

import { initIntl } from "@canva/app-i18n-kit";

const intl = initIntl();
async function getPublishConfiguration() {
  return {
    status: "completed",
    outputTypes: [
      {
        id: "post",
        displayName: intl.formatMessage({
          defaultMessage: "Feed Post",
          description:
            "Label shown in the output type dropdown for publishing to social media feeds",
        }),
        // ...
      },
    ],
  };
}

To learn more about localizing Canva apps, see the official documentation.

Installation

For React apps

npm install @canva/app-i18n-kit react-intl && npm install --save-dev @formatjs/cli

For non-React apps

npm install @canva/app-i18n-kit @formatjs/intl && npm install --save-dev @formatjs/cli

Usage

If you're using the Canva Apps SDK starter kit, the @canva/app-i18n-kit package is already configured.

To migrate an existing Canva app or to use @canva/app-i18n-kit in an app not based on the starter kit, follow the instructions in Migrate an existing app in the Canva Apps SDK documentation.

Changelog

See the CHANGELOG.md file.

Contributing

We're actively developing this package but are not currently accepting third-party contributions. If you'd like to request any changes or additions to the package, submit a feature request via the Canva Developers Community.

License

See the LICENSE.md file.

版本与发布记录

@canva/app-i18n-kit 共发布 14 个版本,首次发布于 2024/09/10;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.3.0latest2026/07/283 个月前
1.2.02025/12/1010 个月前
1.1.12025/10/011.1 年前
1.1.02025/09/301.1 年前
1.0.32025/06/181.4 年前
1.0.22024/12/101.9 年前

其他发布通道:beta → 0.0.1-beta.6。

关于 @canva/app-i18n-kit 的常见问题

@canva/app-i18n-kit 是什么?

Internationalization kit for Canva apps. Adapts react-intl and @formatjs/intl to work with the Canva Apps SDK localization process

如何安装 @canva/app-i18n-kit?

在项目目录运行 npm install @canva/app-i18n-kit,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@formatjs/intl(>=2.10.4 <=3.1.8)、intl-messageformat(>=10.5.14 <=10.7.18)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@canva/app-i18n-kit 支持 TypeScript 吗?

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

@canva/app-i18n-kit 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@canva/app-i18n-kit 可以商用吗?

@canva/app-i18n-kit 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@canva/app-i18n-kit 的下载量有多少?

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

@canva/app-i18n-kit 还在维护吗?

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