Skip to content

Latest commit

 

History

History

l10n_languages

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 language names in 157 different locales. For Flutter ready widgets (like language picker) please use world_countries package. For Dart-only use - it's recommended to use together with sealed_languages package.

Features

  • 157 locales supported out of the box.
  • Three-letter ISO 639-2/T Terminological code lookup.
  • Fallback locale support.
  • Allows injecting custom translations to extend/modify existing ones.
  • Alternative names support.

Getting started

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

dependencies:
  l10n_languages: any

Then import the package in your Dart code:

import 'package:l10n_languages/l10n_languages.dart';

Usage

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

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

  /// Define some ISO codes to localize (e.g., `ENG` for English,
  /// `RUS` for Russian, etc.).
  final isoCodes = {"ENG", "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: 6".

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

FAQ

Why should I use this package over any other currency-related package?

  • 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