Skip to content
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

Stop automatically updating translations #88

Open
hugomelo opened this issue Feb 23, 2023 · 6 comments
Open

Stop automatically updating translations #88

hugomelo opened this issue Feb 23, 2023 · 6 comments

Comments

@hugomelo
Copy link

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.

@leolabs
Copy link
Owner

leolabs commented Mar 8, 2023

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.

@hugomelo
Copy link
Author

hugomelo commented Mar 8, 2023

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

@leolabs
Copy link
Owner

leolabs commented Mar 9, 2023

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?

@hugomelo
Copy link
Author

hugomelo commented Mar 9, 2023

It recreates the default directoy and saves the files there

@brodly
Copy link

brodly commented Oct 11, 2023

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

@leolabs
Copy link
Owner

leolabs commented Oct 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants