question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

serverSideTranslations + client side translation

See original GitHub issue

Do 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:closed
  • Created a year ago
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
adraicommented, Aug 12, 2022
1reaction
adraicommented, Jul 29, 2022

@pedrodurek any idea?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found