-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[next-intl] Not parsing the namespace key correctly when using getTranslations #1170
Comments
The fix is on another post but here is the solution :
{
"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
languageIds:
- 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 |
The fix posted by @DarioLopes works great if you only have one instance of |
Here's an update: #1009 (comment) |
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
![image](https://private-user-images.githubusercontent.com/127468/341564327-f77a0f05-b2cb-47c2-9355-d9e5feb3f7c4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjU4MTMsIm5iZiI6MTczOTQyNTUxMywicGF0aCI6Ii8xMjc0NjgvMzQxNTY0MzI3LWY3N2EwZjA1LWIyY2ItNDdjMi05MzU1LWQ5ZTVmZWIzZjdjNC5wbmc_WC1BbXotQW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LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.fSrHMX30obB8kBG0S5VV4tz61vw4lTQSnxk37RJE8wU)
![image](https://private-user-images.githubusercontent.com/127468/341565123-2934a4d7-3510-48be-93d9-812b6f418fff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjU4MTMsIm5iZiI6MTczOTQyNTUxMywicGF0aCI6Ii8xMjc0NjgvMzQxNTY1MTIzLTI5MzRhNGQ3LTM1MTAtNDhiZS05M2Q5LTgxMmI2ZjQxOGZmZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxM1QwNTQ1MTNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yODY1Y2FjMThlMjU2MmQyZDE3YTIyOWM2N2EwZWM3MTIzYzg0N2NkZjMzNTM5OGMyZGMyNTJmMjBkNDM1NGQ2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.1XA2SUq-fpteqxtH3cVFE7-563IiEeB-Fg2Kn1tLpLo)
The text was updated successfully, but these errors were encountered: