serverSideTranslations + client side translation
See original GitHub issueDo you have a documentation issue?
I wanted to load some translations serverside and some dynamic ones client side. Depending on data recieved so backend sends only id and translation are loaded client side, the client sides are ones that dont appear on screen on first load so i can lazy load them for more performance.
At least in documentation didnt find a clear way to do it as if i use “serverSideTranslations” then client side new namespaces wont load. I did this but not sure if this is correct (inspired on available documentation).
const { t, i18n } = useTranslation([`item_${item}`]);
const translate = useCallback((key: string) => {
if (item)
i18n.reloadResources(i18n.resolvedLanguage, [`item_${item}`])
return t(key)
}, [item])
It mainly to contribute and not just complain as this seems to work for me.
Issue Analytics
- State:
- Created a year ago
- Comments:27 (15 by maintainers)
Top Results From Across the Web
Next-i18next - GitHub
The easiest way to translate your NextJs apps. ... a server environment, whereas getInitialProps is called on the client side when navigating between...
Read more >All side optimized Next.js translations (a next-i18next guide)
Optimize your Next.js app to best work with translations on server side and on client side with next-i18next.
Read more >SSR (v9) - react-i18next documentation
Pass language and translations down to client By doing so the translations won't be loaded and initial clientside render will avoid any flickering...
Read more >Add translation on server side only using next-i18next
I have a map "domain":"translation.json"; Each client has a single language: a user visiting "example.com" will see the website in English only.
Read more >Full-Stack JavaScript I18n Step by Step | Phrase
You see the translated page by refreshing the page ... This way, you can pass them along to the client side as globals....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This: but I don’t recommend: https://github.com/locize/next-i18next-locize#possibility-2-config-for-locize-live-download-usage (Possibility 2)
@pedrodurek any idea?