This is a VSCode-based frontend internationalization (i18n) helper plugin that helps developers quickly and conveniently implement code internationalization, avoiding tedious switching and comparison. This plugin is a secondary development based on copy-json-path (some features have been added or removed) and provides additional useful functionalities.
- 🔍 Quickly find existing i18n entries (select Chinese text, right-click, and choose a replacement format to auto-replace)
- 🚀 One-click replacement of selected text with an i18n path
- 🤖 AI-powered automatic generation of i18n keys and automatic insertion into the configured file and JSON path (based on iFlytek Spark AI)
- 📝 Support for multiple custom i18n formats (
t
,$t
,{{t}}
, etc.) - 💾 Automatically save newly added i18n entries
- 🎯 Customizable i18n file path settings
If the generated key already exists, the plugin will notify you to modify and insert again.
- Search for
frontend-i18n-plugin
in the VSCode extensions marketplace and install it.
- Download the latest version of the plugin from the Releases.
- In VSCode, go to Extensions, click the three dots menu, and choose
Install from VSIX
.
- Configure the plugin settings as needed.
- Done! You can start using it.
Configure the following settings in VSCode:
-
Set the format for copying JSON paths when right-clicking in a JSON file. A default format and three custom formats are available.
-
Set the path to your i18n files. Customizable paths with different priorities (higher priority paths are searched first).
-
Configure key-value pairs for new i18n entries, specifying the target file and JSON path.
-
Set the API key for iFlytek Spark AI to enable AI-generated i18n keys and custom prompts.
-
Configure text replacement formats when selecting content for internationalization. Three formats are available and can be customized.
-
Copy i18n Path
- In a JSON file, select the key you want to copy.
- Right-click and choose a format to copy the JSON path in different styles (customizable formats).
-
Replace with i18n Path
- Select the text to replace.
- Right-click and choose
Replace with i18n Path
, supporting three formats (configurable insettings
):- Format 1:
t('path.to.key')
- Format 2:
{{t('path.to.key')}}
- Format 3:
$t('path.to.key')
- Format 1:
-
Add New i18n Entries
- Select the text and right-click to choose a replacement format.
- If no matching i18n entry is found, an input box will appear.
- Manually enter the key or click the AI icon to generate one automatically.
- Confirm the key, and it will be automatically saved and used for replacement.
Contributions are welcome! Feel free to submit issues or pull requests.
MIT License © 2024