1

Ok, maybe the question is not very precise. But, I figured out that the only way to have something similar to Android's <string-array> for translation in Flutter is to use select. For instance,

"pronoun": "{gender, select, male{he} female{she} other{they}}",
"@pronoun": {
  "description": "A gendered message",
  "placeholders": {
    "gender": {
      "type": "String"
    }
  }
}

Now, how can I get the array of keys that are used in creating this definition? In the upper case, the answer should be [male, female, other].

Draško
  • 2,119
  • 4
  • 41
  • 73

1 Answers1

0

If you look at the generated code in your localization language specific file (i.e. localization_en.dart), you will see the following:

@override
String pronoun(String gender) {
  String _temp0 = intl.Intl.selectLogic(
    gender,
    {
      'male': 'he',
      'female': 'she',
      'other': 'they',
    },
  );
  return '$_temp0';
}

Since the map is generated and stored directly in the method. Without any further research on my part: you have no external way of getting it.

Unless there is a localization specific builder option to generate it (look up the docs), then the above holds true.

offworldwelcome
  • 1,314
  • 5
  • 11
  • I know that, thanks. That's why I asked the community if someone maybe some genius idea how to bypass that obstacle – Draško Jul 21 '23 at 09:40