Open ellisio opened 2 months ago
The fix is on another post but here is the solution :
.vscode
folder (at the root of your project, create it if it doesn't exist)settings.json
(it will be the settings for this project only, overriding VScode global settings. You'll do the same for every project you do) and add this :{
"i18n-ally.enabledFrameworks": ["custom"], // * This is the fix for the getTranslations issue
"i18n-ally.localesPaths": ["src/i18n/messages"], // Change it to match your folder with all the JSON messages
"i18n-ally.sourceLanguage": "en", // Language that will replace the key on the file
"i18n-ally.sortKeys": true // On key edit through the plugin, sort the JSON
}
note that only i18n-ally.enabledFrameworks
is part of the fix, other settings are here just to show how it works / more options.
i18n-ally-custom-framework.yml
. Paste this contentlanguageIds:
- javascript
- typescript
- javascriptreact
- typescriptreact
usageMatchRegex:
- "[^\\w\\d]t\\(['\"`]({key})['\"`]"
scopeRangeRegex: "(?:useTranslations\\(|getTranslations\\(|namespace:)\\s*['\"`](.*?)['\"`]"
monopoly: true
The repo where the solution is can be found here and I found this thanks to @ixartz answer
Describe the bug When using
getTranslations({ locale, namespace: "Metadata" })
inside of thegenerateMetadata()
function, the parsing is incorrect. I would expect this to return onlytitle
, as that is the only item in that namespace inen.json
.Extension Version
v2.12.0
Framework/i18n package you are using
next-intl
To Reproduce
.vscode/settings.json
config:Device Infomation
Extension Log
Screenshots