EH i18n - VS Code Create Locale Key
A VS Code extension for creating a new key in a JSON locale file and replacing selected text with a reference to that key.
Features
- Creates a new key in a JSON locale file and replaces selected text with a reference to that key
- Supports custom locale file path
- Suggest existing keys whose value is the selected text
- Sort the json file
Usage
Creation
Place the mouse cursor on the string and click to Light bulb icon or Cmd + . to see code actions

Using command (Legacy)(Ctrl + Shift + P or Cmd + Shift + P and search for EH i18n - Create Locale Key )

NOTE: For nested keys, separate the keys with -- (e.g. parent--child--grandchild )

NOTE: If the the text exists, suggest existing keys whose value is the selected text

For editing message of an existing key.
Place the mouse cursor on the string and click to Light bulb icon or Cmd + . to see code actions

Using command (Legacy)(Ctrl + Shift + P or Cmd + Shift + P and search for EH i18n - Edit Locale Message )
Configuration
The extension can be configured with the following settings:
createLocaleKey.localeFilePath : The file path to the JSON locale file (default: src/packages/eh-locale/lang/en-AU.json )
createLocaleKey.withBrackets : Whether to format the replacement reference with brackets (default: false )
createLocaleKey.sort : Whether to sort the keys in alphabetical order (default: false ).
NOTE: Sorting criteria:
- Sort the keys alphabetically.
- Sort the keys with dots after keys without dots.
- Sort keys whose values are objects after those whose values are strings
If createLocaleKey.sort is checked:

Known Issues
Release Notes
0.0.6
Initial release of Create Locale Key
0.0.9
Add sort and suggestion of existing keys
0.1.0
Add edit message
0.1.1
Support code action providers and add key to more correct position
Contributing
Pull requests and bug reports are welcome. Happy coding 🤍
| |