-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Bug with t()
and <T />
when set language
option (translate in context language instead parameter language if parameter language is not cached yet)
#3230
Comments
t()
and <T />
when set language
optiont()
and <T />
when set language
option (translate in context language instead parameter language if parameter language is not cached yet)
Hey, I think this is not a bug. But I guess it's a bit confusing. Tolgee doesn't load language automatically when you call Since the fallback language is set to |
Hello, So I think the wording of the documentation is unclear. My understanding of doc was tolgee will loadRecord if needed. And I thought it's a handy approach. As a user of tolgee api, I think I should not have to worry about the cache (and advanced features) of tolgee, when I use the basic api to translate. So my suggestion to you is to take care of this usage so auto loadRecord if needed. If for you the API is good like this, your product your rules and no problem, but please at least improve the wording of documentation. maybe something like
|
The thing with auto loading is that it's not ready right away, so you would still had to solve the loading state in your app. Otherwise for a brief moment tolgee would display invalid translations anyway (english in case of fallback or just key names). So this is kinda design decision to force you to solve this yourself. I was considering an edge case, because usually you have whole your app in one language and only rarely you need simultaneously display multiple languages, so it was considered ok, to keep it a bit more "manual". I'll try to improve the docs about this. |
Thank you |
Hello,
You'll find a complete reproduce bug example here :
https://stackblitz.com/edit/gpbse5j-tolgee-language-param-wycsuw?file=src%2FApp.tsx
When you setup language option in
t()
or<T />
and this language is not cached by tolgee yet, it display the translation in language from tolgee context.My workaround is a hook calling
tolgee.loadRecord
in components where I need to display some translations from an entity language parameter. but it's quite annoying.SDK should take care of language param and call loadRecord if needed (as explained in doc)
https://tolgee.io/js-sdk/api/core_package/tolgee#t
Best regards,
The text was updated successfully, but these errors were encountered: