ngettext method
Translates a plural string using the default textdomain
gt.ngettext('One thing', 'Many things', numberOfThings)
@param msgid String to be translated when count is not plural @param msgidPlural String to be translated when count is plural @param count Number count for the plural @returns Translation or the original string if no translation was found
Implementation
String ngettext(
String msgid,
String msgidPlural,
int count, {
String? domain,
String msgctxt = '',
}) {
final translation = this._getTranslation(
domain ?? this.domain,
msgctxt,
msgid,
);
final index = _pluralsFunc(count);
if (translation == null ||
translation.msgstr.length <= index ||
translation.msgstr[index].isNotEmpty != true) {
_warn('No translation was found for '
'msgid "$msgid" in msgctxt "$msgctxt" and domain "$domain"');
return (count > 1) ? msgidPlural : msgid;
}
return translation.msgstr[index];
}