slang-i18n / slang

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

Support plurals in enums #124

Open BenevidesLecontes opened 1 year ago

BenevidesLecontes commented 1 year ago

Describe the bug Im not able to generate translations using enums as params and pluralization.

"assetTypePlural(param=assetType)": {
      "stock": {
        "one": "{count} ação",
        "other": "{count} ações"
      },
      "stockIndex": {
        "one": "{count} índice",
        "other": "{count} índices"
      }
    }

Throws exception in this line: digestedMap[entry.key] = entry.value as StringTextNode;

type 'PluralNode' is not a subtype of type 'StringTextNode' in type cast
package:slang/builder/builder/translation_model_builder.dart 328:52
Amphaal commented 1 year ago

This would be a great feature to add ! Looking forward to it :)

Tienisto commented 1 year ago

The generated code will look quite complicated and I don't know a clean solution for that.

This technically implies, that you can nest any leaf with any other leaf. (Leaves are: String, RichText, Plural, Context (Enum))