slang-i18n / slang

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

Unexpected parenthesis in linked translations with enums #181

Closed DaleLaw closed 6 months ago

DaleLaw commented 6 months ago

Describe the bug When using a linked translation in conjunction with an enum linked translation, the former unexpectedly generates parentheses. This leads to a syntax error in the strings.g.dart file, preventing it from being compiled.

hello: "Hello"
gender(context=Gender): {
  male: "male",
  female: "female"
}
hello_gender: "@:hello, @:gender"

strings.18n.yaml

String get hello => 'Hello';
String gender({required Gender context}) {
  switch (context) {
    case Gender.male:
      return 'male';
    case Gender.female:
      return 'female';
  }
}
String hello_gender({required Gender context}) => '${_root.hello()}, ${_root.gender(context: context)}';

strings.g.dart

Expected behavior It should generate _root.hello instead of _root.hello()

Tienisto commented 6 months ago

Fixed in v3.28.0