leolabs / json-autotranslate

Translate a folder of JSON files containing translations into multiple languages.
MIT License
139 stars 41 forks source link

Issue with Inaccurate Caching Behavior in json-autotranslate Across Multiple Directories #114

Open veneliniliev opened 4 months ago

veneliniliev commented 4 months ago

This package exhibits inaccurate caching behavior when the command is executed across multiple directories containing translation files with identical names.

Steps to Reproduce:

  1. Execute the command json-autotranslate -i src/translations/a; json-autotranslate -i src/translations/b; json-autotranslate -i src/translations/b; where there exist translation files with the same name (a.json, for example) in the specified directories (src/translations/a, src/translations/b, etc.).
  2. Observe the caching behavior of the package.

Expected Behavior: The package should cache the translation data for each file separately, ensuring accurate translation results even when files with the same name exist in multiple directories.

Actual Behavior: The package fails to cache the translation data accurately, leading to inconsistencies or incorrect translations when files with identical names are present in different directories.

leolabs commented 4 months ago

Hey @veneliniliev,

I hadn't thought of this use case yet, let me see if I can fix this. In the meantime, you could run json-autotranslate from each of the directories, like this:

(cd src/translations/a && json-autotranslate -i .); (cd src/translations/b && json-autotranslate -i .); (cd src/translations/c && json-autotranslate -i .);

This creates a separate cache per directory.

veneliniliev commented 4 months ago

@leolabs thanks. I'll try.