commonNameFor<B extends L> method

String commonNameFor<B extends L>(
  1. B mainLocale, {
  2. B? fallbackLocale,
  3. bool useLanguageFallback = true,
  4. String orElse = "",
})

Returns a localized common name for this object.

Parameters:

  • mainLocale: Required primary locale for translation lookup
  • fallbackLocale: Optional secondary locale to use if main locale translation is missing.
  • useLanguageFallback: Whether to try language-only codes when specific locale not found.
  • orElse: Default value to return if translation is not found, defaults to empty string.

Example:

// Returns German common name for the language or `orElse` if not found.
final name = language.commonNameFor(const BasicLocale(LangDeu()));

Implementation

String commonNameFor<B extends L>(
  B mainLocale, {
  B? fallbackLocale,
  bool useLanguageFallback = true,
  String orElse = "",
}) =>
    l10n.commonNamesMap(
      {this},
      options: LocaleMappingOptions<B>(
        mainLocale: mainLocale,
        fallbackLocale: fallbackLocale,
        useLanguageFallback: useLanguageFallback,
      ),
    )[this] ??
    orElse;