-
Notifications
You must be signed in to change notification settings - Fork 55
Added Caching #4
base: master
Are you sure you want to change the base?
Conversation
I found a bug where the Script stopped when it found a # (Specific case of special characters). Using the encodeURIComponent instead of encodeURI solves this issue.
Bug with Special Characters
Here, I added a caching feature. It overrides the existing translated file, if the key already exist in the previously translated file, it doesn't make the request to the Google Translate API, instead it reuses the value. The only condition is that you keep your files in the tmp folder on the root level of the project and when you update your original JSON File it will check bot the updated JSON and updates the older translated versions with new keys and values.
Added Caching
…ge file do not exist already
Hi, I just grabbed the changes from your PR and tested locally. It works well. Thank you for your work. |
Ohh I've just seen t his PR, and since it wans't merger to master, I'd to develope this feature for myself. Also, i added a different way of translating string using package "google-translate-api-browser" which lets you use Google Translet without an API key. |
Cool stuff @urielgolab I merged my caching branch to master from my fork I think this project is dead, we might want someone to take over somehow, maybe create a new repo with the continuation of the code in it? Also we might want to consider bumping the node version Let me know what you think |
@serafdev Nice to see some activity. I missed this years ago with the original pull request for some reason. Clearly, I haven't updated this recently. I am happy to redirect the repo to one of you, and make that clear in the README. Just let me know. |
I just found useful and very useful to translate some randomly defined JSON
files.
If you can add me as a contributor, I could push my code to let anybody
translate without having an API key.
Also, I needed to cached keys persisted on the disk because the free usage
of googles Api rejects requests after a few responses.
El mar., 2 jun. 2020 a las 22:00, Trevor Ewen (<[email protected]>)
escribió:
… @serafdev <https://github.com/serafdev> Nice to see some activity. I
missed this years ago with the original pull request for some reason.
Clearly, I haven't updated this recently. I am happy to redirect the repo
to one of you, and make that clear in the README. Just let me know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEC2I7CHRFO6DZPGRRRYCDRUWODHANCNFSM4D7DTV3Q>
.
|
Will do @urielgolab |
@tewen hey Trevor, thank you for this code by the way! Are you able to add an open License on the main repo too? We’ll pull that on the inherited repository. @urielgolab if you are actively working with google translates it would be better if you take care of this, I’ll be happy to continue contributing |
I just made some changes to use this module freely but my changes will drop
the multilingual solution as this was designed for.
I would push my code to a new branch so anybody could check that out.
PR has more work ahead...
El mar., 2 jun. 2020 a las 22:32, فارس (<[email protected]>)
escribió:
… @tewen <https://github.com/tewen> hey Trevor, thank you for this code by
the way! Are you able to add an open License on the main repo too? We’ll
pull that on the inherited repository.
@urielgolab <https://github.com/urielgolab> if you are actively working
with google translates it would be better if you take care of this, I’ll be
happy to continue contributing
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEC2I67TFXRBZQULZTA3ZTRUWR3RANCNFSM4D7DTV3Q>
.
|
Great, are you able to merge this one @urielgolab, I use this version of the code, and we should still be able to have both options (free and with api), we should keep that in mind! Some cases won't work with the free version (chat bots, etc) where throughput can be high |
haha yes, I'm working with chatbots indeed.
I've made some changes to work with and without API key, and also have
multilingual support for caching.
Won't do the tests with an API key, but will leave that part untouched.
El mié., 3 jun. 2020 a las 11:47, فارس (<[email protected]>)
escribió:
… Great, are you able to merge this one @urielgolab
<https://github.com/urielgolab>, I use this version of the code, and we
should still be able to have both options (free and with api), we should
keep that in mind!
Some cases won't work with the free version (chat bots, etc) where
throughput can be high
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEC2I6JHKREL6EIZK3MABTRUZPB3ANCNFSM4D7DTV3Q>
.
|
Here I added Caching to the translation script. First the output files need to remain in the new tmp/ folder that I created (changed the output from /tmp/ to ./tmp/ which is root of project. You need to keep the translated files so we can reuse the translated strings. For example if you modify the base json, it will only translate the newly added keys.
Fixed a bug with Special Characters stopping the script running because of encodeURI, we now use encodeURIComponent to be able to encode special characters.