Translations

Translations

All entity names (countries, languages, currencies, continents, and capitals) can be retrieved in multiple languages.

Available Locales

CodeLanguage
daDanish
deGerman
enEnglish
esSpanish
frFrench
itItalian
zhChinese

Country Names

final country = Country.fromAlpha2Code('US');

// Using a Locale object
final name = country?.displayNameFromLocale(Locale('de'));
print(name); // Vereinigte Staaten

// Using BuildContext (in a widget)
final contextName = country?.displayName(context);

Language Names

final lang = Language.fromCode('en');
final name = lang?.displayNameFromLocale(Locale('fr'));
print(name); // anglais

Currency Names

final currency = Currency.fromCode('USD');
final name = currency?.displayNameFromLocale(Locale('it'));
print(name); // Dollaro statunitense

Continent Names

final continent = Continent.fromCode('EU');
final name = continent?.displayNameFromLocale(Locale('da'));
print(name); // Europa

Capital Names

final country = Country.fromAlpha2Code('JP');
final name = country?.displayCapitalFromLocale(Locale('fr'));
print(name); // Tokyo

Accessing Translation Maps Directly

For bulk operations, you can access the full translation maps.

// Translation maps are accessible via delegate classes
final germanCountries = CountriesTranslationsDelegate.translations['de'];
germanCountries?.forEach((code, name) {
  print('$code: $name');
});

// Other available delegates:
// LanguagesTranslationsDelegate.translations
// CurrenciesTranslationsDelegate.translations
// ContinentsTranslationsDelegate.translations
// CapitalsTranslationsDelegate.translations