-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Reducing the size of locales that will be downloaded on page load by specifying namespaces #321
base: main
Are you sure you want to change the base?
Conversation
@salmanorak is attempting to deploy a commit to the Tom Team on Vercel. A member of the Team first needs to authorize it. |
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.
Thanks for the PR! However we'd like to support the same feature in both Pages and App Router, ideally with the same API, but getLocaleProps
is only present when using the Pages Router.
We have to find a way to support this feature when using the App Router too, it would make a big difference.
Yes, it makes sense to have a common API and solution for both router options. Then maybe a common config on the project level can be used here to sync namespace requirements for server components, client components, and the Pages router. i18nConfig : {
pages: {
'*' : ['common','errors'], //namespaces that will be required for all pages can be represented like this.
page1: [ 'ns1'],
page2: ['ns2' ],
page3: [ 'ns1', 'ns2.subnamespace' ], // subnamespaces can be used like this.
page4/[:id] : [ns4] // dynamic pages can be represented like this.
}
} Then this config can be used in the code to pick the correct set of localization keys. With this, the appropriate function that will implement this logic can be picked for each router and component type. I think for the pages and router What do You think about this approach? PS: Maybe we may need to add a rule that will let the user pick a namespace list for all pages that are under a specific path. For example, all pages under /dashboard path should have ['dashboard'] namespaces. |
this library does that splitting the dictionries would be soo huge |
@zakidze i18next/next-i18next isn't compatible with the app router and RSC. |
I just want to share my thought about implementation suggestion. We can create a page-namespace mapping configuration, that can be used by both Router options. App Router
Pages Router We can consume same page-namespace configuration and filter the dictionaries on the server Side before they have been passed to client. The candidate location can be getLocaleProps or any step that is completed on the server. |
Thanks for sharing your thoughts @salmanorak. Completely agree with what you've said:
|
any update on this topic?,????? |
Hello @QuiiBz,
I have a proposal for one issue that has been mentioned in the issue #312.
I have also implemented a basic implementation with this PR.
The suggestion is to let users add namespaces that will be used for that specific page and let them reduce the downloaded locale size.
I have added 2 tests.
Please feel free to make comments on it. I just struggled with types a little bit. You may want to check them if You find the solution beneficial.