gettext method

String gettext(
  1. String msgid, {
  2. String? domain,
  3. String msgctxt = '',
})

Translates a string using the default textdomain

gt.gettext('Some text')

@param msgid String to be translated @returns Translation or the original string if no translation was found

Implementation

String gettext(
  String msgid, {
  String? domain,
  String msgctxt = '',
}) {
  final translation = _getTranslation(domain ?? this.domain, msgctxt, msgid);

  if (translation == null || translation.msgstr[0].isEmpty) {
    if (_locale != 'en') {
      _warn('No translation was found for '
          'msgid "$msgid" in msgctxt "$msgctxt" and domain "$domain"');
    }
    return msgid;
  }

  return translation.msgstr[0];
}