QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.28k stars 59 forks source link

question: if i have app with alot of pages and alot of translations .... #312

Closed zakidze closed 9 months ago

zakidze commented 9 months ago

if i have app with alot of pages and alot of translations will it load only the required translation for each page

example i have home page , about page, contact page

will home translations string loads when accssing about page?

say i everypage is static and just 1 page is dynamic product/[id] does the whole translatiosns get loaded only for the this page ? or just the product strings???,

QuiiBz commented 9 months ago

Assuming you're using Client Components, no the whole locales file will have to be loaded, because you can dynamically generate the key of a translation so we don't know which ones are used at build time.

salmanorak commented 9 months ago

@QuiiBz Here I have a suggestion about letting the user specify the namespaces they want to use on the page. This pattern is mostly used on other i18n solutions.

This can limit the number of keys that will be downloaded for that page.

These namespaces can be passed to getLocaleProps function or they can be defined on the configuration file.