-
Notifications
You must be signed in to change notification settings - Fork 390
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
Some translated texts using the t(like txxx
) method did not take effect when switching languages.
#1757
Comments
Thank you for your reply, but my main pain point here is: Upgrading from v3.15.0 to v4.4.2, there are many business pages and components, and each component needs to add I would like to know if there is a better way to upgrade. |
There was a change in a I18nProvider #1501 following discussion from there could help with migration. In short - you can copy a version of i18nProvider from v3 and use it in your application if you need to force remount children when switching languages. |
Here is the migration paragrpagh about that https://lingui.dev/releases/migration-4#i18nprovider-no-longer-remounts-its-children-on-locale-change |
Can I open this discussion again? Even if we use v3 @zengkaiwen did you find any solution yourself? 🙏 |
@maiderhernandorenatoqio https://lingui.dev/releases/migration-4#i18nprovider-no-longer-remounts-its-children-on-locale-change
|
One general tip, don't switch languages in runtime. Just reload whole page, this is one time event for your users but resolve tons of issues related to i18n in the app and save dozens of developers hours. This is not exactly related to lingui or any other i18n library. It's just a common sense. To switch in runtime you should keep track on all your loaded data and state to reload it with the actual locale. |
Describe the bug
When upgrading the project from lingui v3.15.0 to v4.4.2, the translated text declared using the
t
method inside the page components does not take effect when switching languages.To Reproduce
A demo has been created to reproduce the issue: Demo. Please refer to the code file Page1.tsx for the relevant code.
The translations enclosed in {t`xxx`} do not take effect. However, this syntax is supported in lingui v3.15.0.
Expected behavior
The
t
method should correctly switch the language for the translated text in the new version.Additional context
4.4.2
@babel/core@7.22.11
@lingui/swc-plugin
babel-macro-plugin
.babelrc
) or framework you use (Create React App, NextJs, Vite)Vite
The text was updated successfully, but these errors were encountered: