A VS Code extension for creating a new key in a JSON locale file and replacing selected text with a reference to that key. Also supports showing translation on hover, jumping to translation definitions, and locale key autocomplete suggestions.
Features
Creates a new key in a JSON locale file and replaces selected text with a reference to that key
Supports showing translation on hover, jumping to translation definitions, and locale key autocomplete suggestions.
Supports custom locale file path
Suggest existing keys whose value is the selected text
Sort the json file
Usage
Translation Hover, Jump to Definition and Autocomplete Suggestions
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
None at the moment.
Release Notes
0.1.7
Support showing translation on hover, jumping to translation definitions, and locale key autocomplete suggestions.
Use esbuild for bundling.
Update default locale fallback path to work with eh-mobile-pro repo by default.
0.1.1
Support code action providers and add key to more correct position
0.1.0
Add edit message
0.0.9
Add sort and suggestion of existing keys
0.0.6
Initial release of Create Locale Key
Contributing
Pull requests and bug reports are welcome. Happy coding 🤍