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

A simple internationalization package.

EzI18n ๐ŸŒโœจ #

EzI18n is a lightweight internationalization (i18n) library for Flutter. It simplifies managing translations and supports dynamic parameter replacement, making multilingual apps easy to develop. ๐Ÿš€

Features ๐Ÿ› ๏ธ #

  • ๐ŸŒŽ Support for generic (pt) and specific (pt_BR) locales.
  • ๐Ÿ”„ Dynamic parameter replacement (@{name}).
  • ๐Ÿ›ก๏ธ Fallback mechanism for missing translations.
  • ๐Ÿ“ฆ Seamless integration with Flutter's localization framework.

Getting Started ๐Ÿ #

Installation ๐Ÿ“ฅ #

Add EzI18n to your pubspec.yaml:

dependencies:
  ezi18n: ^1.0.0

Run:

flutter pub get

Observation ๐Ÿ“ #

For native Widget translation, you will need the flutter_localizations package to use the delegates, as shown in the example below.

Usage ๐Ÿš€ #

  1. Define translations: ๐Ÿ—‚๏ธ
import 'package:ezi18n/ezi18n.dart';

class AppMessages implements EzMessages {
  @override
  Map<String, Map<String, String>> get keys => {
    'en': {'greeting': 'Hello, @{name}!'},
    'pt': {'greeting': 'Olรก, @{name}!'},
  };
}
  1. Set up localization in your app: โš™๏ธ
import 'package:ezi18n/ezi18n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      locale: Locale('en'),
      localizationsDelegates: [
        EzI18nDelegate(AppMessages()),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: [Locale('en'), Locale('pt')],
      home: MyHomePage(),
    );
  }
}
  1. Use translations: ๐Ÿ“
import 'package:flutter/material.dart';
import 'package:ezi18n/ezi18n.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('greeting'.tr(context, params: {'name': 'Alice'}))),
      body: Center(child: Text('greeting'.tr(context, params: {'name': 'Alice'}))),
    );
  }
}

Contributions ๐Ÿค #

Contributions are welcome! ๐ŸŽ‰ Feel free to open issues or submit PRs on GitHub.

License ๐Ÿ“œ #

EzI18n is available under the MIT license. ๐Ÿ›ก๏ธ

0
likes
140
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

A simple internationalization package.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_test, intl

More

Packages that depend on ezi18n