slang-i18n / slang

Type-safe i18n for Dart and Flutter
https://pub.dev/packages/slang
MIT License
474 stars 39 forks source link

Only apply changed strings in `_missing_translations.json` #129

Closed adil192 closed 1 year ago

adil192 commented 1 year ago

Motivation When I'm applying translations, there is usually only one language that's changed at a time. I therefore need to type in

flutter pub run slang apply --locale=zh-Hant-TW

which is quite tedious especially with the longer locale codes.

Developer Experience I propose a new flag, e.g.

flutter pub run slang apply --only-changed

which would only apply translations from locales that have changed from the default translation file.


e.g.

{
  "@@info": [
    "Here are translations that exist in <en> but not in secondary locales.",
    "After editing this file, you can run 'flutter pub run slang apply --locale=<locale>' to quickly apply the newly added translations."
  ],
  "cs": {
    "eg": "This is the (unchanged) English translation."
  },
  "de": {
    "eg": "This is the (changed) German translation."
  }
}

Running flutter pub run slang apply --only-changed on the above would be equivalent to

flutter pub run slang apply --locale=de
Tienisto commented 1 year ago

Thanks for noticing this UX issue!

I think that applying unchanged translations is never useful. So instead of adding a flag, flutter pub run slang apply will only apply changed locales by default. The developer can still use --locale= to apply a specific locale where it might be the same (en-US, en-GB).

Changed in v3.14.0