Replies: 1 comment
-
You need to use
Once RSC support is added, you will be able to use AsyncLocalStorage to pass values.
It's not, useEffect is basically this, a hook that doesn't return anything, that hooks runs an effect, it's provided so you don't need to do it yourself.
Feel free to use whatever you want, but in remix-i18next case specifically there are no dependencies, only peer dependencies on react-router (you already have it), i18next (so you can upgrade it independently), react (you already have it too), and react-i18next (again so you can upgrade it yourself) If you only read the locale from the params, you can probably skip remix-i18next and use i18next directly in your loaders/actions when you need it. You may end up doing what remix-i18next does at the end. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to change
lang
attribute of<html>
element.The locale is derived entirely from URL pathname, so no magical guessing on IP/headers/search params and no dependence on async logic.
I have a structure where a root path
/
has a separate layout route with a language selector. It can't derive language at this point so it can't show standard layout with header and footer, since those depend on locale. The locale guess is a best effort on client to show "choose language" text. The rest of the paths start with/:locale
and are children of the standard layout. So I basically have 2 "root" layouts with different locale resolution logic.Looking at the
remix-i18next
example, it uses a hook in the layout function, but wouldn't it turn all pages into client components, speaking in context of possible RSC support?Then it uses another hook in app function, presumably for side effects since it doesn't use its return value. Which is a pretty bizzare pattern for react code.
I specifically want to avoid installing a package with quadrillion dependencies and reliance on unstable features and several levels of indirection for multilang support, so this example for sure doesn't bring more clarity into situation.
Beta Was this translation helpful? Give feedback.
All reactions