I'm currently localizing my flutter app using the intl package.
I have a localised text that contains two placeholders: userName
and dayCount
, where I have used the plural syntax for dayCount
.
Here is the snippet from my .arb file:
"prolongationRequested": "{userName} requested prolongation by {daysCount, plural, =1{1 day} other{{daysCount} days}}",
"@prolongationRequested": {
"placeholders": {
"userName": {},
"daysCount": {}
}
},
So far so good, but the auto generated method in the AppLocalizationsEn
class completely ignores everything from the text except the daysCount
placeholder. This is the generated method:
String prolongationRequested(Object userName, num daysCount) {
return intl.Intl.pluralLogic(
daysCount,
locale: localeName,
one: '1 day',
other: '$daysCount days',
);
}
My expectation would be for the method to look like this:
String prolongationRequested(Object userName, num daysCount) {
final String pluralString = intl.Intl.pluralLogic(
daysCount,
locale: localeName,
one: '1 day',
other: '$daysCount days',
);
return '$userName requested prolongation by ${pluralString}';
}
Interestingly enough the method gets generated correctly if I remove one of the placeholders, or if I remove the plural syntax from daysCount
.
Why is the method not being generated as expected?
You may adapt your plural on the
prolongationRequested
var inside the .arb file using this configuration or similar: