-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Provide i18n instance even when serverSideTranslations is not used #1049
Comments
P.S.: I can come up with a PR if you agree. |
I'm not sure Relevant documentation for fallback pages can be found here. In general, I wonder how the Vercel team expects users to translate fallback pages, or if this use case was overlooked entirely. I would start by enquiring on the NextJs repo, rather than fetching translations on the client side, via HTTP. |
Right, the fallback was just an example why it would be useful to have the I don't see any reason where not having it there is better that having it there, while having it provided even without translations allows reuse of the same configuration everywhere.
Translations through HTTP is necessary in certain situations. For example, I don't necessarily want to preload translations for parts of the app that my users might rarely access, dynamic options with translations for select components and authentication locked translations to name a few. |
Feel free to work on a PR. Just bear in mind it will need test coverage. Thanks! |
+1. I'd like this for cases with dynamic routes where using getStaticPaths just isn't feasible and getServerSideProps causes unnecessary latency. For instance if you have a user specific dashboard (located at like There's one better solution and that is for Next.js to make it possible to use getStaticProps without getStaticPaths for dynamic routes but I don't see that happening anytime soon: vercel/next.js#14200 Edit: #993 seems like a dupe, but was closed. |
What is the current way of doing for dynamic routes that do not require getStaticProps or getServerSideProps other than for translations? Nextjs requires to have getStaticPaths if getStaticProps is used for dynamic routes. I could use this solution with fallback: true but considering that serverSideTranslations is the only props in getStaticProps, it will build exactly the same file over and over again and I will end up with 1000s of identical pages. Am I missing something? |
Fetching translations client side is a huge requirement for us since we load components dynamically and they define the namespaces required. It was recommended to use |
@skrivanos and @njarraud There is currently not a possible solution for this, I didn't have time to work on a PR yet, however it probably would be necessary to use the @dcodus You actually have to use |
@jvcmanke Thank you! Everything works as expected now! |
Quick question, based on reading these issues + the documentation, I have the following set up. I feel like I'm close but I keep getting a
|
@austinhale You are missing |
@isaachinman I’m new to the library so I’m still getting up to speed. Are you saying I should include the |
@austinhale Yes, if you want to use |
@isaachinman What if I am redirecting to another component from server.js or index.js file then how can I receive props in that component provided that I amj not passing any props on redirecting to the component but just using simple resirectTo: '/specificComponent'. How can I ensure that |
@isaachinman Hi, I have been searching hopelessly (in all closed/old issues) for any example of fetching translations from a remote API (server-side); I know it's not really to do with this lib but just documentation for i18next doesn't suffice either. Could you please point me in the right direction? You mention here it should be possible. My current setup is as follows: next-i18next.config.js module.exports = { In _app I manually pass the config into appWithTranslation as described in the README. From the docs for I'd be more than happy to add to the ReadMe afterwards as I can image others struggle with this and have in the past (even though the setup of next-i18next was way different then. |
Hey @annbeemsterboer — I'm out of office until next week, but I believe @adrai has an example of using Locize as a backend? |
@annbeemsterboer This next.js example with i18next-locize-backend may help: https://github.com/locize/next-i18next-locize |
@adrai thanks for the example! I keep getting the error
my package.json contains
Do you have any ideas? |
instead of |
Thanks a million! |
Is your feature request related to a problem? Please describe.
When using
getStaticPaths
withfallback: true
the fallback page does not rungetStaticProps
however I still want to render the translations for my_app
or other components like loading spinner test using my i18next configuration.I can do it using
i18next-http-backend
as I do with a few parts of my UI, however in this case the configuration is not loaded and i get the warning:Because
next-i18next
only adds theI18NextProvider
if_nextI18Next
is present inpageProps
.Describe the solution you'd like
Always wrap with the
I18NextProvider
just don't provide any server side translations.Describe alternatives you've considered
I could wrap with my own instance but I don't see a reason
next-i18next
should't always provide thei18n
instance.Additional context
This would also mean that dynamic routes that don't want to use
getStaticProps
/getStaticPaths
could still utilize the samei18n
instance/configuration to fetch their translations client-side.The text was updated successfully, but these errors were encountered: