intlayer-usage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Intlayer Usage

Intlayer 使用指南

To use Intlayer effectively:
  1. Retrieve Locales: Check
    intlayer.config.{ts,js,json,json5,jsonc,cjs,mjs}
    ,
    .intlayerrc
    to see the configured locales.
  2. Declare Content: We recommend creating one content declaration file per component, located alongside the component file. This keeps translations close to the code.
  3. Consume Content: Use the provided hooks and functions to access your content.
    • Intlayer Exports
    • React Intlayer Exports
    Common Packages:
    • intlayer
      : Core package for content declaration and utility functions.
    • react-intlayer
      : React components and hooks (e.g.,
      useIntlayer
      ).
    • vite-intlayer
      : Vite plugin for integration.
  4. CLI Commands: Useful commands for managing your content:
    • npx intlayer build
      : Build the dictionaries from your content declarations.
为了有效使用Intlayer:
  1. 获取区域设置(Locales):查看
    intlayer.config.{ts,js,json,json5,jsonc,cjs,mjs}
    .intlayerrc
    文件,查看已配置的区域设置。
  2. 声明内容: 我们建议为每个组件创建一个内容声明文件,与组件文件放在同一目录下。这样可以让翻译内容贴近代码。
  3. 使用内容:使用提供的hooks和函数来访问你的内容。
    • Intlayer 导出内容
    • React Intlayer 导出内容
    常用包:
    • intlayer
      :用于内容声明和工具函数的核心包。
    • react-intlayer
      :React组件和hooks(例如
      useIntlayer
      )。
    • vite-intlayer
      :用于集成的Vite插件。
  4. CLI 命令: 用于管理内容的实用命令:
    • npx intlayer build
      :从内容声明构建字典。

References

参考资料

  • Get Started
  • How Intlayer Works
  • Why Intlayer
  • Per-locale File
  • 快速开始
  • Intlayer 工作原理
  • 为什么选择Intlayer
  • 按区域设置划分的文件