locize/locize-cli

Reference lang won't get updated values if skip-delete is enabled

Closed this issue · 9 comments

hixus commented

Reference lang won't get updated values if skip-delete is enabled and there are extra keys in locize. This seems to be caused by 'somethingToUpdate' flag which removes reference lang from downloadAll if any changes are detected (even if skipped).

Would assume that values are always updated from locize and skipDelete would just skip the extra keys.

adrai commented

Can you provide more information?
How does your complete sync command look like? have you set --update-values true ?
How does the cli output look like when using the --dry true flag?

hixus commented

command is just locize sync --language-folder-prefix 'public/locales/' --namespace translation --skip-delete true

U can test it by:

  1. create reference language file like {"key1": "key1 initial text", "key2": "key2 initial text"}
  2. sync it to locize with locize sync --skip-delete true
  3. delete key2 from local reference file only
  4. update key1 value directly in locize to "key1 updated text"
  5. run locize sync --skip-delete true again
  6. Key1 won't get the updated text from locize

With current behaviour the end result in local is {"key1": "key 1 initial text"} but it should be {"key1": "key1 updated text"}

hixus commented

cli version is locize-cli@7.6.0

adrai commented

Ahh, now I know what you mean.

local is master, but you skip the delete...
without the skip-delete it would delete that key from locize...

Why would you expect the key to be downloaded again locally?

This is like a conflict...

hixus commented

Ahh, now I know what you mean.

local is master, but you skip the delete...
without the skip-delete it would delete that key from locize...

Why would you expect the key to be downloaded again locally?

This is like a conflict...

local is master for translation keys, locize is master translation values. Branch might be different so we don't want to delete extra keys from locize automatically.

key2 should not be downloaded again as it's extra but key1 translation value should be. I think for non-extra keys the behaviour should be always the same. I updated my original example to be bit more specific but here's example what happens if there are no extra keys in locize.

  1. create reference language file like {"key1": "key1 initial text", "key2": "key2 initial text"}
  2. sync it to locize with locize sync --skip-delete true
  3. delete key2 from local reference file only
  4. update key1 value directly in locize to "key1 updated text"
  5. run locize sync --skip-delete true again
  6. Key1 got the updated text from locize, end result locally {"key1": "key1 updated text", "key2": "key2 initial text"}
adrai commented

Thank you very much for all this information.
Can you try again with v7.6.1 ?

hixus commented

Thank you very much for all this information.
Can you try again with v7.6.1 ?

Seems to work thank you.

Noticed though that non ref languages get all the keys from locize (not just the onces local ref lang has defined) but with that we can live (and previous versions did that also).

The usecase here is that developers create the keys in code repository and people who translate use locize. The end product has all the translations embedded so the code and translations match.

Is this related to skip-delete flag or was this behaviour there without this flag also. I am also facing something similar on version 7.0.3 but we don't use this skip-delete

adrai commented

@rishabh876 Can you update your cli version and try again? In case you have an issue, please open an new issue.