i18n_extension:getstrings and plural
chriscdn opened this issue · 5 comments
chriscdn commented
I'm using i18n_extension:getstrings
to generate a .pot
file. What I can't figure out is how to provide a plural string. For example, in my .dart
file I have this:
String message = '%d day'.plural(days)
This gets extracted into the .pot
file as follows:
msgctxt "..."
msgid "%d day"
msgid_plural "%d day"
msgstr[0] ""
Ideally, I'd like the third line to be:
msgid_plural "%d days"
Is this a limitation of the parser, or am I missing something?
marcglasberg commented
Maybe @bauerj can help answering? He's the creator of the getstrings helper.
bauerj commented
Sorry, but this is currently just not implemented. See #102 (Proposal 2) for some more information.
marcglasberg commented
@bauerj Should I close this? Is it already tracked there?
bauerj commented
I guess so, yes.
chriscdn commented
If it matters, I worked around the issue with the following extension:
extension Pluralize on String {
String pluralize(int i, String pluralText) {
if (i == 1) {
return this.fill([i]);
} else {
return pluralText.fill([i]);
}
}
}
Usage:
return "%s day".i18n.pluralize(durationDays, "%s days".i18n);
Thanks for the great package!