Please help me to create the intl localization arb file
I'd like to have a localizable string with the placeholder for an integer value with leading zero if integer value is less than 10.
Here is a part of the arb file:
"notificationScheduled": "The notification has been scheduled for {min}:{sec}",
"@notificationScheduled": {
"placeholders": {
"min": {
"type": "int",
"format": "decimalPattern",
"example": "23"
},
"sec": {
"type": "int",
"format": "00",
"example": "43"
}
}
}
min value and sec values are supplied from the Dart code.
var min = 10;
var sec = 8;
Text(AppLocalizations.of(context)!.notificationScheduled(min, sec))
I'd like to have sec value for seconds formatted with leading zero if it is less than 10.
The problem is that both 0# and 00 format strings are not accepted when app_localizations files are generated.
flutter gen-l10n --template-arb-file=app_en.arb
raises error
Number format 00 for the sec placeholder does not have a corresponding NumberFormat constructor.
Check the intl library's NumberFormat class constructors for allowed number formats.
I've tried optionalFormat with customPattern and error has gone but there are no leading zero in the result string.
"sec": {
"type": "int",
"format": "decimalPattern",
"example": "43",
"optionalParameters": {
"decimalDigits": 0,
"customPattern": "0#"
}
}
The sec value does not have leading zero when formatted with customPattern:0#.
The text value is like 10:8 but I'd like to have 10:08.
Is it possible to adjust arb file localization format to have leading zero in the result string ?