TranslatedExtension<T extends TranslatedName, L extends BasicLocale, N extends Object> extension

An extension that provides translation methods for objects implementing the IsoTranslated interface.

The TranslatedExtension extension adds methods to objects that implement the IsoTranslated interface. It provides convenient ways to retrieve translations based on the specified language, country code, and script.

Example usage:

TranslatedCountry country = ... // An object implementing the Translated interface

TranslatedName translation = country.translation(BasicLocale(
  LangAar(), // The desired language.
  countryCode: 'DE', // Optional country code filter.
  script: const ScriptLatn(), // Optional script filter.
  ),
  orElse: const LangEng(), // Default language if no translation is found.
);

In this example, the country object is an instance of a class that implements the IsoTranslated interface. By using the translation method provided by the TranslatedExtension extension, you can retrieve the translation for a specific language. The method accepts the desired locale BasicLocale with required NaturalLanguage, optional countryCode, script, and a default orElse language if no translation is found. It returns the translation as a TranslatedName object. If no translation is found for the specified language, it falls back to the orElse language.

on

Methods

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

Available on IsoTranslated<T, N, L>, provided by the TranslatedExtension extension

Returns a localized common name for this object.
maybeCommonNameFor<B extends L>(B? mainLocale, {B? fallbackLocale, bool useLanguageFallback = true, String? orElse}) String?

Available on IsoTranslated<T, N, L>, provided by the TranslatedExtension extension

Returns a localized common name for this object or null if not found.