Last updated:
0 purchases
flutter i18n converter
Flutter I18n Converter #
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
copied to clipboard
then run:
$ flutter pub get
copied to clipboard
or
flutter pub add flutter_i18n_converter
copied to clipboard
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)
}
copied to clipboard
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
}
copied to clipboard
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.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.