flutter_i18n_converter 0.0.3 copy "flutter_i18n_converter: ^0.0.3" to clipboard
flutter_i18n_converter: ^0.0.3 copied to clipboard

Simplify Localization with Effortless Language Code Conversion

Flutter I18n Converter #

pub package Flutter Analysis Last Commits Pull Requests Code size GitHub License

Flutter I18n Converter is a simple and lightweight library to convert language short codes (like en or en-US) to their respective long names (like English or English (United States)).

Features #

  • Convert language short codes to their long names in English.
  • Convert language short codes to their long names in their own language (autonyms).
  • Support for regional variations (e.g., en-US, fr-CA).
  • Configurable to use either English or autonyms as default.

Installation #

Add the following to your pubspec.yaml file:

dependencies:
  flutter_i18n_converter: ^0.0.3

then run:

$ flutter pub get

or

flutter pub add flutter_i18n_converter

Usage #

Basic Usage #

import 'package:flutter_i18n_converter/flutter_i18n_converter.dart';

void main() {
  // Get the language name in the default language (autonym)
  print(I18nConverter.getLanguageName('en')); // Output: English
  print(I18nConverter.getLanguageName('es')); // Output: Español

  // Get the language name in English
  print(I18nConverter.getLanguageNameInEnglish('fr')); // Output: French
  print(I18nConverter.getLanguageNameInEnglish('zh-Hans')); // Output: Chinese (Simplified)

  // Get the language name in autonym
  print(I18nConverter.getLanguageNameInAutonym('de')); // Output: Deutsch
  print(I18nConverter.getLanguageNameInAutonym('pt-BR')); // Output: Português (Brasil)
}

Configuration (Changing Default Behavior) #

By default, I18nConverter returns the language name in its own language (autonym). You can change this to always return the language name in English:

import 'package:flutter_i18n_converter/flutter_i18n_converter.dart';

void main() {
  I18nConverter.setUseAutonyms(false);

  print(I18nConverter.getLanguageName('en')); // Output: English
  print(I18nConverter.getLanguageName('es')); // Output: Spanish
}

Contribution #

Contributions are welcome! If you have any suggestions or improvements, please create an issue or submit a pull request.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

3
likes
160
points
40
downloads

Documentation

API reference

Publisher

verified publishernetronk.com

Weekly Downloads

Simplify Localization with Effortless Language Code Conversion

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_i18n_converter