json-autotranslate icon indicating copy to clipboard operation
json-autotranslate copied to clipboard

Stop automatically updating translations

Open hugomelo opened this issue 2 years ago • 6 comments

I would like to know if there's a way to avoid translation updates as I am having the following issue. I have the texts back in a button which is translated by Google to dutch as rug, but I actually want terug. When I make the correction directly to the nl.json file and call json-autotranslate again I see rug is back.

Note I haven't changed the original text, I have only changed the dutch translation.

hugomelo avatar Feb 23 '23 10:02 hugomelo

Hmm, that sounds like a bug. Usually, json-autotranslate doesn't overwrite keys unless they have changed in the source files. Do you see a .json-autotranslate-cache dir being created after translating your source files? That folder contains the last version of all files so the script can compare differences.

leolabs avatar Mar 08 '23 19:03 leolabs

I understood what happened today. I have two different locales being loaded as my project generates two different applications. image Above you can see I use different locales dir and the .json-autotranslate-cache dir is ignoring the paths

I saw you have a --cache parameter but that's not working. This parameter would solve our issue

hugomelo avatar Mar 08 '23 19:03 hugomelo

What happens when you set this parameter to a different folder, e.g. --cache .locales-cache or something similar? Does the folder get created or do you get an error message?

leolabs avatar Mar 09 '23 00:03 leolabs

It recreates the default directoy and saves the files there

hugomelo avatar Mar 09 '23 10:03 hugomelo

i have a somewhat related question. Im looking to run translations thru a CI and wanted to use the cache dir to prevent making translations on keys which have already been translated but do not have access to past translations (only access to the cache files).

This is my project setup

Source directory - This holds all the source files in english

translation
|- source
  |- common.json
  |- namespace.json
  |- namespace2.json

Locales directory - Use a script to auto generate this structure and provide the dir to json-autotranslate. This is the output where the en directory is just a cp of the source dir above

dist
|- locales
  | - fr
  | - en
    | - common.json
    | - namespace.json
    | - namespace2.json
  | - it

What I found is that your tool does a diff against the language source files (not the en base file) and the cache files and in my case it will see the language source files are all empty and will query the translation service even tho my actual source file (the en file) hasnt changed. Is there is a way to tell json-autocorrect to pull in the cache translations into the matching language if the lang source does not exist (i.e fr dir is empty, but fr cache has translations so pull those in).

Basically trying to prevent source controlling both the full set of translations and the .cache files

brodly avatar Oct 11 '23 00:10 brodly

Unfortunately, there currently isn't a way to have json-autotranslate use cached translations if the translated files don't exist yet. As a workaroud, you could think of caching both the .json-autotranslate-cache and your output directory in your CI so you don't have to version-control any of the generated files yourself.

leolabs avatar Oct 30 '23 12:10 leolabs