-
Notifications
You must be signed in to change notification settings - Fork 380
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
Interpolated values not shown in production #385
Comments
Hey @fagerbua, do you load compiled message catalogs to your app? You can compile them either manually and then import |
Thanks for putting me on the right track! Your comment lead me to do the obvious thing: to check if strings are translated at all when I use a non-default language. Turns out they are not, so it's likely an issue with the catalog loading. You've likely considered it already, but I wonder if it's possible to have some sort of warning when this happens unintentionally? As long as you stick to the default language, it's not obvious. |
@fagerbua know it's a pretty old issue, but I'm facing the same issue right now. Do you remember what exactly was the cause in your scenario? I'm having this only production mode. It's with the default language, but I'm importing even the default Imported object with catalogs seems to look fine - it's a function that takes one parameter, and looks like it should be replaced but still seeing the I just discovered that this happens only for my default language, which is english. When I try with other one it works fine, even for the same string. |
I think I found a solution:
I didn't pass catalogs to setupI18n, nor set the language. This helped.
Leaving just in case anyone has the same problem. |
I'm having the same problem, this solution doesn't work for me. Could you post your .linguirc file as well? Thank you. |
@aohua
So for me it started to work when language was set to existing language (the one that you have files for), but if you set current language to not existing one, the interpolation failed. So what I did is: export function setLocaleWithFallback(locale) {
if (locale && catalogs[locale]) {
return locale;
}
return DEFAULT_LOCALE;
}
<I18nProvider
i18n={i18n}
language={setLocaleWithFallback(sessionConfig.locale)}
catalogs={catalogs}
> Where import enCatalog from './translations/en/messages.po';
// Import additional languages here
export default {
en: enCatalog,
}; Hope that helps you. |
Describe the bug
Interpolation of values in translated strings doesn't work in production. During development it works perfectly fine, but in production my app shows texts like 'Log out: {username}`. There are no crashes or error messages.
To Reproduce
The behavior occurs whenever I build the project with
NODE_ENV=production
. I can try to make a minimal reproduction if necessary, just wondering if you have any ideas what might be causing this before I do so.Expected behavior
This should work in production as it does during development.
Additional context
I've experimented with different ways of providing the
i18n
object (withI18n, I18n), and also tried using macros, but that makes no difference.The problem disappears if I manually modify
node_modules/@lingui/core/index.js
to always require./cjs/core.development.js
.2.7.0
babel-core@7.0.0-bridge.0
The text was updated successfully, but these errors were encountered: