sxtfv / flutter_arb_translator

A command line tool for translation of Flutter ARB files
MIT License
9 stars 5 forks source link

Feature request: it would be nice to add a parameter for translating target labels, which are equal to source ones. #7

Closed slavap closed 1 year ago

slavap commented 1 year ago

Example: app_en.arb

{
  "hello": "Hello world"
}

and app_de.arb is actually the same, because many translation utils add a label to all arb files simultaneously, i.e. if refactoring chosen for "Hello world" string in the code, this string will be added to all existing arb files.

So it would be nice to have a parameter to enforce translation for labels with the same content as in source arb.

{
  "adult": "Adult",
  "numAdults": "{num, plural, one{1 Adult} other{{num} Adults}}",
  "ok": "OK",
  "close": "Close"
}

{
  "adult": "Erwachsene",
  "numAdults": "{num, plural, one{1 Erwachsener} other{{num} Erwachsene}}",
  "ok": "OK",
  "close": "Close"
}

in this case "ok" and "close" labels should be sent for translation (if parameter specified), because they are the same in EN and DE arb files.

sxtfv commented 1 year ago

Could you please confirm that I understand your request correctly? Sometimes we just copy-paste *_en.arb file for other locales and you want to translate only entries which are not translated (equal in source & target file) by specifying a command argument? Did you try to use the -k ok -k close to translate only these entries or it is not suitable solution?

slavap commented 1 year ago

@sxtfv yes, let’s say after strings “extract” I have 50+ new keys in EN and DE arb files. They are not added manually, intl_utils just adds them to all arb files automatically (untranslated). List them all in -k is just impractical.

sxtfv commented 1 year ago

@slavap okay, I will add it

sxtfv commented 1 year ago

@slavap I just pushed an update (1.0.11) which adds a new command line argument --translate-equal or -e which enables requested feature

slavap commented 1 year ago

@sxtfv Thank you, it works, but I don't think it is good idea to count equal empty labels.

flutter_arb_translator:main.
08-21-2023 19:24:14 [ARBTranslator] TRC: Started translation from en to [de]
08-21-2023 19:24:14 [ARBTranslator] TRC: Total entries count: 21
08-21-2023 19:24:14 [ARBTranslator] TRC: Unmodified entries count: 15
08-21-2023 19:24:14 [ARBTranslator] TRC: To translate entries count: 6
==============================================================
findTitle
[en] [SRC]: ""
[de] [EDT]: "" -> ""

==============================================================
findTopMsg
[en] [SRC]: ""
[de] [EDT]: "" -> ""

==============================================================
findBottomMsg
[en] [SRC]: ""
[de] [EDT]: "" -> ""

==============================================================
invoiceDetails
[en] [SRC]: "Details"
[de] [EDT]: "Details" -> "Einzelheiten"

==============================================================
amountDue
[en] [SRC]: "Amount Due"
[de] [EDT]: "Amount Due" -> "Fälliger Betrag"

==============================================================
ok
[en] [SRC]: "OK"
[de] [EDT]: "OK" -> "OK"
sxtfv commented 1 year ago

@slavap sure, I didn't consider this. Will fix soon

sxtfv commented 1 year ago

@slavap fixed in 1.0.12, actually empty strings were not translated (the package did not send an API request to translate it) but were considered as edited. Now they are considered as unmodified

slavap commented 1 year ago

@sxtfv Thank you, it works great now.