Skip to content
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

i18next client side is not initialized without a UI framework #66

Open
dallyh opened this issue Nov 10, 2022 · 0 comments
Open

i18next client side is not initialized without a UI framework #66

dallyh opened this issue Nov 10, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@dallyh
Copy link
Contributor

dallyh commented Nov 10, 2022

Hi!

This is a follow up to: #37 (comment)

Basic example of this is created here: https://github.com/dallyh/astro-i18n-client-server-example-react which is basically the astro-i18next React example slightly modified.

  • folder react is with the Counter react component added on the pages.
    • i18next is in this case set to detect language with query string and or path (and both work when there's a react component ready and hydrated). Also i18next logs to browser console.
  • folder without-react-component is the same as react but just without the Counter component on the pages.
    • i18next is in this case is set the same way, but now there is no console output

In both cases strings which are on the Astro pages are translated server side when the server is run or the project is built, which means they are not dynamic in any way for ex. that the URL query (?lng=XX) does not change them (and that is fine).

Basically what happens is that i18next does not get loaded client side, when there's no UI framework present and hydrated on a page. I guess that this makes sense, because i18n runs with injectScript: before-hydration, and when there is nothing to hydrate, then, i18n just doesn't load.

Although this makes sense to me, I would like to have this confirmed, and maybe added to the documentation.

Thanks a lot!

@yassinedoghri yassinedoghri added the documentation Improvements or additions to documentation label Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants