-
Notifications
You must be signed in to change notification settings - Fork 38
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
Support config for don't use cache #78
Comments
Doesn't discardOldKeys option solve your use-case? Can you provide a complete repoduction scenario? I'm no sure to understand completely what you expect and what is the output. |
@gilbsgilbs the component file has key k1
the plugin will put
i translate
change component with new content
the plugin will put
|
Definitely unexpected. It should never overwrite values you have modified. |
The problem is we will never reload file content before write |
I tested this out and I'm still unable to reproduce. As far as I know, the cache you're referring to is non-persistent. Do you run babel in some esoteric environment (like within a watcher or something) that could explain why the cache would be kept across runs? I'm not sure reloading the original file over and over again is safe. |
I have the same trouble. I'm using |
A few observations when using webpack-dev-server in 'watch' mode, the old keys won't get discarded, and the plural contexts will be overwritten with the original value if you perform any edits directly within the json file. My current workaround is to stop webpack-dev-server before making any manual changes to the json file, then restart it. And to discard old keys simply restart webpack-dev-server. |
Sorry for the delay. That's very interesting, thank you. It makes much more sense to me now 😄 . Does anybody have a clear idea on what would be the proper fix? The first idea that comes to my mind is to disable extraction when watch mode is detected, but is it even possible to detect it? Or maybe it would be preferable to find a way to invalidate the cache at the right moment, but I'm not sure it's possible 🤔 . |
I'm running into the same issue developing an Expo app, and it's really cumbersome to have to restart the packager every time I need to edit the translations files. 😕 |
Yea, having the same issue with react + HMR. Seems like we can catch |
I just started using this plugin and also got this problem. I run webpack dev server, which incrementally builds project on changes. I expect that manual changes, applied to the file will not be overwritten back by cached ones. I expect behavior like with the regular code: new items should be added, manually changed items should remain changed. Without this behavior plugin is practically useless, because rebuild whole project takes too long time to perform it after each manual change of translations. |
I'm using i18next-parser instead now, and I just run it via an npm script whenever I need to, beats having to restart the dev server every time I change a string... 😅 This is my |
Should i18next-parser work with Trans component? It doesn't work for me |
@gilbsgilbs |
@urrri Actually I don't know, maybe it doesn't. I always use the |
Having the same issues as described above, but on top of that as I have 'discardOldKeys': true, it also removes most of the strings from the translation file each time I change some string during the dev server is running I assume it has something to do with cache, as if I simply run babel it can give the same result, unless I manually clear the cache first it really annoys and breaks dev process now. Anyone has any idea how to fix it? |
I just defined separate npm task and babel config just to run that plugin. When I need update translations I run it manually without watcher. |
Im facing the same issue. I am also using babel-loader and webpack (with watch in dev mode). |
Hello! Here is a feature request to support that behavior. I was facing same issues with my webpack setup |
I'm now using the <Trans i18nKey="login:form.labels.acceptance">
<Link external to="/tos">
Terms of Service
</Link>
<Link external to="/privacy">
Privacy Policy
</Link>
</Trans> # login.json
{
"form": {
"labels": {
"acceptance": "I have read and agree to the <0>Terms of Service</0> and the <1>Privacy Policy</1>."
}
} |
Here is my config
The problem is when I edit the translation file, after that, I add a new key in component, It will write to the translation file the old content with new key, the content I have edited is lost in the wild. So, I need a config for disable cache in this line
babel-plugin-i18next-extract/src/exporters/index.ts
Line 122 in 55894ca
Thank you 🙏
The text was updated successfully, but these errors were encountered: