-
Notifications
You must be signed in to change notification settings - Fork 322
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
add keyPath support for react-i18n-next #770
base: main
Are you sure you want to change the base?
Conversation
@terales can you check it? |
Thanks for the help, I defenitely need this feature! However I pulled your PR and are having two problems:
The correct key should be 'common.component.title' and 'common.action.page'. Would you kindly fix it? |
@soapwong703
in my realization extension can work only be configured in file scope so you shoud have only one component in one file, but you can help me to fix it
|
Hi @vovsemenv how is this PR going ? Looking forward to it ! :) |
i guess it waiting for @terales review |
|
||
function detectedKey(key: string, documentText?: string): string { | ||
if (!documentText) return key | ||
const mathces = documentText.match(/useTranslation\(.+,\s*{\s*keyPrefix:\s*["'`](?<keyPath>.+)["'`]\s*}\s*\)/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, little typo here ! ;)
const keyPath = mathces?.groups?.keyPath | ||
if (!keyPath) return key | ||
|
||
return `${keyPath}.${key}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the key separator should be dynamic, as it can be configured in the i18nally configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test here (at least as a small e2e test to the https://github.com/lokalise/i18n-ally/tree/main/examples/by-frameworks)?
Allow keyPath support for react-i18n-next
useTranslation
hookcloses #719