l10n_countries 1.0.0 copy "l10n_countries: ^1.0.0" to clipboard
l10n_countries: ^1.0.0 copied to clipboard

Provides country names translations (for 194 different locales).

CodeFactor Codecov CodeRabbit Dart Code Metrics CI checks Pub points Last commit GitHub stars License MIT Pub package

This ISO-driven, pure Dart, fully tested and dependency-free package provides translations for country names in 194 different locales. For Flutter ready widgets (like country picker) please use world_countries package. For Dart-only use - it's recommended to use together with sealed_countries package.

Features #

  • 194 locales supported out of the box.
  • Three-letter ISO 3166-1 Alpha-3 code lookup.
  • Fallback locale support.
  • Alternative names support.

Getting started #

To use this package, add l10n_countries as a dependency in your pubspec.yaml file.

dependencies:
  l10n_countries: any
copied to clipboard

Then import the package in your Dart code:

import 'package:l10n_countries/l10n_countries.dart';
copied to clipboard

Usage #

Use the CountriesLocaleMapper class to localize country names. Create an instance and use the localize method to get translations:

void main() {
  /// Create an instance of the mapper directly.
  final mapper = CountriesLocaleMapper();

  /// Define some ISO codes to localize (e.g., `USA` for United States,
  /// `RUS` for Russian Federation, and `POL` for Poland).
  final isoCodes = {"USA", "RUS", "POL"};

  /// Localize the codes with an optional main locale (e.g., "sk" for Slovak),
  /// and an optional fallback locale (e.g., "cs" for Czech).
  final localized =
      mapper.localize(isoCodes, mainLocale: "sk", fallbackLocale: "cs");

  print("Names count: ${localized.length}"); // Prints: "Names count: 12".

  /// Print out the localized names.
  localized.forEach(
    (country, l10n) => print(
      'Localized name of country with ISO code "${country.isoCode}" '
      'for locale "${country.locale}" is "$l10n"',
    ),
  );
}
copied to clipboard

FAQ #

  • No dependencies: This package has no dependencies, ensuring that you won't have any issues or conflicts with other dependencies (no even meta here, because of that).
  • Rich data: This package offers tons of translations (all GlobalMaterialLocalizations and GlobalCupertinoLocalizations locales and more).
  • High code coverage: The code in this package has 100% code coverage, providing confidence in its reliability and stability.
  • Comprehensive documentation: This package provides full documentation for every non-code generated public member, usually with examples, ensuring clarity and ease of use.
  • Industry adopted: This package is actively used in production by numerous European companies, ensuring its efficacy and robustness in real-world scenarios.
  • Lightweight: This package keeps under 500 KB, ensuring it fits within the pub cache limit. This leads to quick, low-bandwidth downloads and faster caching, minimizing resource impact.
  • MIT license: This package and sources are released under the MIT license, which is a permissive license that allows users to use, modify, and distribute the code with minimal restrictions. The MIT license is considered better than most other open-source licenses because it provides flexibility and allows users to incorporate the code into their projects without worrying about legal implications.

Additional information #

If you like this package, please give it a star or like. For more information on using this package, check out the API documentation. PRs or ideas are always welcome. If you have any issues or suggestions for the package, please file them in the GitHub repository.

References, credits and sources #

1
likes
160
points
713
downloads
screenshot

Publisher

verified publishertsin.is

Weekly Downloads

2024.09.25 - 2025.04.09

Provides country names translations (for 194 different locales).

Repository (GitHub)
View/report issues

Topics

#l10n #localization #country #translations #countries

Documentation

API reference

License

MIT (license)

More

Packages that depend on l10n_countries