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