slang icon indicating copy to clipboard operation
slang copied to clipboard

Support plurals in enums

Open BenevidesLecontes opened this issue 2 years ago • 2 comments

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

BenevidesLecontes avatar Jan 22 '23 06:01 BenevidesLecontes

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

Amphaal avatar Feb 13 '23 23:02 Amphaal

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))

Tienisto avatar Feb 24 '23 23:02 Tienisto