singular method

String singular([
  1. string? locale
])

Returns the singular form of a plural noun.

Implementation

String singular([string? locale]) {
  if (isBlank) {
    return blankIfNull;
  }

  locale ??= platformLocaleCode;
  if (locale.flatEqualAny(['pt', 'pt_PT', 'pt_BR'])) {
    if (endsWith('ões')) {
      return '${removeLast(3)}ão';
    } else if (endsWith('ães')) {
      return '${removeLast(3)}ão';
    } else if (endsWith('s')) {
      return removeLast(1);
    }
    return this;
  }

  if (endsWith('ies')) {
    return '${removeLast(3)}y';
  } else if (endsWith('es')) {
    return removeLast(2);
  } else if (endsWith('s')) {
    return removeLast(1);
  }
  return this;
}