flutter_localization_plus

pub package License: MIT Flutter Dart

Advanced localization with pluralization, gender-specific text, and RTL support for Flutter applications.

Features

  • ๐ŸŒ Multi-language Support: Easy localization for multiple languages
  • ๐Ÿ”ข Pluralization: Handle singular, plural, and other plural forms
  • ๐Ÿ‘ฅ Gender-specific Text: Support for masculine, feminine, and neutral text
  • โžก๏ธ RTL Support: Full right-to-left language support
  • โšก High Performance: Efficient text caching and management
  • ๐Ÿ›ก๏ธ Type Safety: Type-safe localization keys and parameters
  • ๐Ÿ“ฑ Flutter Integration: Seamless integration with Flutter apps
  • ๐Ÿงช Well Tested: Comprehensive test coverage

Getting Started

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_localization_plus: ^0.0.1

Basic Usage

import 'package:flutter_localization_plus/flutter_localization_plus.dart';

// Initialize localization
final localization = FlutterLocalizationPlus(
  locale: const Locale('en'),
  fallbackLocale: const Locale('en'),
);

// Get localized text
final text = localization.translate('hello_world');

Pluralization Example

// English: "1 item" vs "5 items"
final itemCount = localization.pluralize(
  'item_count',
  count: 5,
  zero: 'No items',
  one: '1 item',
  other: '{{count}} items',
);

Gender-specific Text

// Support for different genders
final greeting = localization.genderize(
  'greeting',
  gender: Gender.male,
  male: 'Hello sir',
  female: 'Hello madam',
  neutral: 'Hello',
);

API Reference

FlutterLocalizationPlus

The main class for handling localization.

Constructor

FlutterLocalizationPlus({
  required Locale locale,
  Locale? fallbackLocale,
  Map<String, Map<String, String>>? translations,
})

Methods

  • translate(String key, {Map<String, dynamic>? args}): Translate a key to the current locale
  • pluralize(String key, {required int count, String? zero, String? one, String? other}): Handle pluralization
  • genderize(String key, {required Gender gender, String? male, String? female, String? neutral}): Handle gender-specific text
  • setLocale(Locale locale): Change the current locale
  • isRTL(): Check if current locale is RTL

Supported Locales

The package supports all locales supported by Flutter, including:

  • English (en)
  • Arabic (ar) - with RTL support
  • French (fr)
  • German (de)
  • Spanish (es)
  • And many more...

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Author

Dhia Bechattaoui

Support

If you encounter any problems or have suggestions, please file an issue at the GitHub repository.