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 aliases for useTranslation function in providing scoped namespaces #1231

Open
TzviPM opened this issue Nov 1, 2024 · 0 comments · May be fixed by #1232
Open

Support aliases for useTranslation function in providing scoped namespaces #1231

TzviPM opened this issue Nov 1, 2024 · 0 comments · May be fixed by #1232

Comments

@TzviPM
Copy link

TzviPM commented Nov 1, 2024

Is your feature related to a specific framework or general for this extension

Yes. react-i18next

Is your feature request related to a problem? Please describe.

Yes. Our application wraps the useTranslation utility provided by react-i18next in order to provide some more fine-tuned DX enhancements for our internal conventions. Our wrapper is named useI18nContext. I noticed that using this wrapper leads i18n-ally to falsely report missing translation keys when relying on an unqualified key using the default namespace. For example:

const {t} = useTranslation(['common', 'someFeature']);

t('some-key');

would correctly be identified as referring to common:some-key because the call to useTranslation changes the default namespace in its scope.

However, the following does not work:

const {t} = useI18nContext(['common', 'someFeature']);

t('some-key');

Describe the solution you'd like

I would like to be able to configure an alternate name or list of names to use for matching the scoped default namespace instead of useTranslation

Additional context

I have already created a proof of concept for this that works quite well for our use case. I based my implementation on e89557c#diff-1945e219acf58a633d45d6d8ef766218782fe79bd75a905659b76934902a075c. that I discovered via #307. I will create a PR with my changes and would love to contribute if you would accept the PR.

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

Successfully merging a pull request may close this issue.

1 participant