-
Notifications
You must be signed in to change notification settings - Fork 397
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
i18n._ does not format values in production build #1076
Comments
I've got the same issue using a custom webpack config |
I have the same issue using CRA webpack config and marking strings with |
Looking at your example, this seems to be an issue that I've seen @tricoder42 answer before many times. The issue is essentially that, when the This brings us to your issue. Your example repo has neither the extracted catalog file nor the compiled catalog file (unless I'm missing something) and these files are critical to get this to work properly. If you |
I am not using catalogs with string extraction because in my use case the localization files are loaded dynamically. |
Ah, I see. I hadn't read that deep in. Cloning your repo and messing around a touch, and I can't get One thing I noticed is your example doesn't have a lingui config (ok, assuming the default config) but you also don't seem to have an instance of babel (I guess its coming from CRA?), or babel macros and if I had to guess, it's the absence of that last one that might be causing the issue. |
I'm not so sure if it is due to lack of a package being installed because it does work in development mode. Another project I have does use additional babel plugins and it also has the same problem. I believe CRA does use babel. |
@AlexSCorey 3.9.0 version of LingUi does have that commit in it. So I downgraded LingUI to the version prior (before #1059) to see if that was the cause. I used the following command lines:
However, the problem is still present in 3.8.10. UPDATE: I have also tried 3.10.2 and it also has the same issue. |
You are right, I'm not using anything special, just create-react-app and lingui. |
Hello guys, @AlexSCorey issue you mentioned was occurring in development environment when we replaced some Plurals' keys for example, we had to re-run extract, this is fixed since 3.9.0. About your issue @nmoinvaz just cloning your repo right now, give a me a few minutes and I take a look. In a fast look I already saw some issues with your repo: |
Thank you @semoal !
|
That's the tick of the story ^^, are these localization remotely compiled? |
If they aren't, basically with the structure when we run On 3.10 I've released a new tool called BUT, there are some issues i'm struggling with (node dependencies with babel that can't be released to front-end), I'll try to get it fixed today. Here it is the pull request where I've introduced this feature(isn't ready to use yet): #1080 |
They aren't compiled. In my main application (not the repo), I am remotely loading json key/value pair files that have the localization id and the string value using When using
But I would be happy to just get the my example repo working. |
I tried with @lingui/core@3.10.2 but the issue still persists. .☹ |
I explained to you, why it fails in the previous comment. It won't work as simply .json because Lingui doesn't accept that, they need to be compiled. I'm working on this feature (since someone requested it too), and this feature could be possibly just using the |
I see. I think I must have missed this comment in the docs for
I will wait for the |
Polish some details and I'll release a new version with this new tool |
Released with 3.10.3 with: import { remoteLoader } from "@lingui/remote-loader" Once I get free 10 minutes, I'll write a section in the documentation |
It might be a good idea to update the example code for |
@semoal how long does it normally take npm to pick up the new release? |
Hm, should be instant give it a try to 3.10.4, just released a fix about remoteLoader. |
Figured it out, works like a charm in development and production builds! Thank you. |
May I know how do you solve? Can you please explain a bit? We are having the same issue |
I ended up using the I suppose I shouldn't have deleted my example repo in the description, but I can't raise it from the dead now.. |
I got the same issues using the |
Describe the bug
When using
i18n._
with the second argument "values" those values are not inserted into the string in production build, but they are inserted into the string in development when runningnpm run start
.To Reproduce
I have created a sample repository that can be used to reproduce the problem:
https://github.com/nmoinvaz/lingui-values-bug
Relevant code file:
https://github.com/nmoinvaz/lingui-values-bug/blob/main/src/App.js
npm install
npm run start
In development the strings are properly replaced:
npm build
serve -s build
In production the strings are not properly replaced:
Expected behavior
The values object should be inserted into the string. For example
{a}
should be replaced with1
.Additional context
The text was updated successfully, but these errors were encountered: