slang-i18n / slang

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

Mark translation as missing if it is an empty string #180

Closed yagmure15 closed 9 months ago

yagmure15 commented 9 months ago

When I leave the key field empty in the JSON file, I can refer to and display the base locale via _fallbackstrategy. However, what I want is to provide a key, set its value as an empty string "", and if the value is empty, the system should refer to the base locale.

Developer Experience I'm using the Tradoura translation system. The management of translations is facilitated through this site. I only want to develop in English, with translations for other languages being handled through the site. The site should allow me to filter out empty values and enter their English equivalents. However, there's an issue when I write a key and leave its value part empty. For example, in the code snippet below, there's a title key with $name. If I make this a blank string, it should read the value from the English file:

{
  "welcome": {
    "title": "Welcome $name"
  }
}
Tienisto commented 9 months ago

This might be slightly breaking if developers expected a string in a particular language to be empty.

yagmure15 commented 9 months ago

Do you think a configuration option similar to fallback_strategy could be added, maybe called empty_value_strategy, to deal with cases where a translation key's value is empty? Is it possible?

Tienisto commented 9 months ago

Added in v3.28.0