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

Handle namespaces automatically #188

Open
bboure opened this issue Jun 29, 2020 · 4 comments
Open

Handle namespaces automatically #188

bboure opened this issue Jun 29, 2020 · 4 comments

Comments

@bboure
Copy link

bboure commented Jun 29, 2020

🚀 Feature Proposal

Allow the scanner to automatically detect and generate the namespaces automatically, without needing to specify them in the ns option.

Motivation

I have a (react-native) project with many namespaces. Basically, one per page/screen. That makes it cumbersome to have to update manually and list all the namespaces in the ns option.

If I forget one, I get the error *** does not exist in the namespaces ***. While this error is useful to identify the issue, it is still not ideal to have to add the namespaces manually since I have dozens of them.

Ideally, I would just like to pass an option to ns (maybe false) so that the plugin will just go ahead and generate any {{lng}}/{{ns}}.json file I need, based on the usage.

Example

const [t] = useTranslate('myNamespace');

return <Text>{t('hello')}</Text>;

If myNamespace exists (the file exists), it should just add the hello key to it.
If not, it should create the file.
All this without the need to have to add myNamespace anywhere in the options.

Thank you

@montogeek
Copy link

You can find a workaround in the meantime here: #142 (comment)

@bboure
Copy link
Author

bboure commented Jun 29, 2020

Thanks @montogeek but this is a different issue. I am using that solution along with useTranslation() and it works great. However, I just want to avoid to have to specify manually all the namespaces in the scanner config. That should just be automatic with usage from the code.

@DannyvanHolten
Copy link

No workaround found?

@pigareva
Copy link

Unfortunately not, #142 (comment) - is not the same. It is about to use the first namespace from useTranslation as a default namespace

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

4 participants