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

outdated

Fast localization solution for flutter apps using Dart's `Map`

fast_localization #

Fast localization solution for flutter apps using Dart's Map. (no context needed for every single localization).

Getting Started #

Add the following to your dependencies in pubspec.yaml

fast_localization: <last_version>

Examples #

Minimal (Out of the box fast_localization MaterialApp) #

import 'package:flutter/material.dart';
import 'package:fast_localization/fast_localization.dart';

void main() async {
  final en = {
    "title": "Demo",
    "welcome": "Hello World!",
  };

  final ar = {
    "title": "عرض",
    "welcome": "أهلاً بالعالم!",
  };

  final locales = {
    Locale('en'): en,
    Locale('ar'): ar,
  };

  await Localization.load(locales);

  runApp(LocalizationApp(
    title: () => Localization.translate('title'),
    home: () => HomeScreen(),
  ));
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      ...
    );
  }
}

When to use:

When you want the home and title of MaterialApp only.

MaterialApp(title: 'App Name', home: HomeScreen());

Full example:

Check out example/fast_localization.dart

Flexible #

You need to install flutter_localizations

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:fast_localization/fast_localization.dart';

void main() async {
  final en = {
    "title": "Demo",
    "welcome": "Hello World!",
  };

  final ar = {
    "title": "عرض",
    "welcome": "أهلاً بالعالم!",
  };

  final locales = {
    Locale('en'): en,
    Locale('ar'): ar,
  };

  await Localization.load(locales);

  runApp(LocalizationApp(
    child: (context) => MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      ...
    );
  }
}

When to use:

When you want to use own MaterialApp, CupertinoApp, or WidgetsApp.

Full example:

Check out example/flexible.dart

TODO #

  • ❌ Add tests
  • ❌ Code factoring
  • ✅ Nested localizations
  • ✅ Auto save/load local
  • ✅ Language code only support Locale('en')
  • ✅ Language and country code support Locale('en', 'US')

PRs are always welcome and appreciated!

3
likes
0
points
50
downloads

Publisher

verified publisherhighestweb.com

Weekly Downloads

Fast localization solution for flutter apps using Dart's `Map`

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_localizations, shared_preferences

More

Packages that depend on fast_localization