-
Notifications
You must be signed in to change notification settings - Fork 79
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
Auto-generated locale file remembers previous keys which are no longer used. #99
Comments
By the way, the code sample above is designed for reproducibility—the actual scenario @chanpory and I were seeing is:
|
The file is not the source of the inside object at any time. That means removing or editing the file will not update the actual object inside i18n. Files are cached and all that stuff. You need to remove the key yourself from the inside object using |
Thanks for the quick response @gjuchault.
I guessed as much, I am saying that is problematic. :) The source of truth should be the file, at least locally—surely caching is not necessary then—to simplify editing. In this scenario there was no opportunity to call |
The file will not be read every time you get a value. Caching is necessary. I didn't get the part where you say you don't have any JS possibilty |
Could you explain why this needs be the case locally, as opposed to in production? It'd be more complex, but I could also envision a system where caching continued to be employed locally, yet the file was the source of truth—using
In our scenario, at no time did we edit any JS. We only edited the HTML template and the localization file. It's actually generally unclear to me where you would call |
You're not supposed to edit a generated file by your library to change the way it works while it's on. The library generates this file. Furthermore, reading a file is a costly operation, compared to a object getter. Using a file watcher would solve a problem that is yours and not i18n-node-2's (see the previous point). In your scenario, you make a mistake and then you want to correct it and make i18n-node-2 refresh its cache by using a file watcher. This looks kinda weird. I'm used to reload my server whenever I make a change inside, or use something like |
Let's back up. How are users of Right? |
Do you think this issue is somehow related to what you mean #97 ? |
Hm, maybe? I could describe what I'm looking for as syncing i18n-node-2's cache with the file. @kokujin, what do you think? |
Repro steps:
Run this code:
Observe that the generated
en.js
file looks like this:Delete
en.js
before the 30 second timeout above elapses.After the timeout elapses, observe that the generated
en.js
file looks like this:Expected result:
i18n appears to keep a representation of the localization file in memory and flush that to disk with every call. Rather, it should treat the file as the single source of truth and just patch that with each call rather than entirely recreating it. By doing the latter, it overrides the developer's intent.
The text was updated successfully, but these errors were encountered: