Skip to content
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

Support for scoped namespace in a JS/TS file #48

Open
aranard opened this issue Dec 1, 2023 · 0 comments
Open

Support for scoped namespace in a JS/TS file #48

aranard opened this issue Dec 1, 2023 · 0 comments

Comments

@aranard
Copy link

aranard commented Dec 1, 2023

When using react-i18next, the useTranslation() hook can accept one or more namespaces, where the first namespace becomes the default scope for the current file.

For example, this is valid syntax:

const { t } = useTranslation('ns1');
t('key'); // finds key from ns1

and this is as well:

const { t } = useTranslation(['ns1', 'ns2']);
t('key'); // finds key from ns1
t('ns1:key'); // finds key from ns1
t('ns2:key2'); // finds key from ns2

Is there some way to recreate this behavior of having a default scoped namespace with the Jetbrains plugin? I've only had partial success with defining a template as t('%namespace%:%key%', %map%), which then means the plugin expects %namespace% is always provided (which as you can see above, is not necessary in react-i18next).

Taking it a step farther, if it were possible to do the above - I'd also like to be able to define a custom scope (rather than react-i18next's useTranslation function) that would add parity with this feature I contributed to the VS Code extension.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant