localizely / flutter-intl-intellij

This Android Studio & IntelliJ plugin generates boilerplate code for localization of Flutter apps with official Dart Intl library
MIT License
129 stars 4 forks source link

Select generating incorrectly with numerical placeholder #111

Closed M4yd3 closed 1 year ago

M4yd3 commented 1 year ago

I have the following select key

"appBarTitle": "{page, select, 0{Home} 1{Order} 2{Chats} 3{Account} other{Error}}",
"@appBarTitle": {
  "placeholders": {
    "page": {
      "type": "int"
    }
  }
}

It should be generating this

String appBarTitle(int page) {
  return Intl.select(
    page,
    {
      0: 'Home',
      1: 'Order',
      2: 'Chats',
      3: 'Account',
      'other': 'Error',
    },
    name: 'appBarTitle',
    desc: '',
    args: [page],
  );
}

But I'm getting this instead

String appBarTitle(int page, Object Home, Object Order, Object Chats,
    Object Account, Object Error) {
  return Intl.message(
    '{page, select, 0$Home 1$Order 2$Chats 3$Account other$Error}',
    name: 'appBarTitle',
    desc: '',
    args: [page, Home, Order, Chats, Account, Error],
  );
}

I figured this is a valid ICU syntax since DevPal understands it perfectly.

lzoran commented 1 year ago

Linking the similar issue.

M4yd3 commented 1 year ago

Well, it's unfortunate that ICU has such definition. Guess I'll just prepend a character to the placeholder.