flutter_localizations_plus 0.1.0 copy "flutter_localizations_plus: ^0.1.0" to clipboard
flutter_localizations_plus: ^0.1.0 copied to clipboard

An enhanced Flutter localization solution that streamlines multilingual integration for seamless app development.

flutter_locations_plus #

pub package pub points GitHub Issues GitHub Forks GitHub Stars GitHub License

An enhanced Flutter localization solution that streamlines multilingual integration for seamless app development.

  • factory: generates AJAX request functions by api URI name in WYSIWYG style.
  • mock: mocking data from a local JSON file for specified requests during development.
  • silent: suppress routing redirection for unauthorized or maintenance responses for specified request.
  • request futures functions generated can be accessed by dot notation.

Platform Support #

Android iOS MacOS Web Linux Windows

Requirements #

  • Flutter >=3.0.0 <4.0.0
  • Dart: ^2.17.0
  • sprintf: ^7.0.0

Getting started #

published on pub.flutter-io.cn, run this Flutter command

flutter pub add flutter_localizations_plus

Steps for Usage in Dart #

  • IMPORTANT: [locale] directory which contains json files MUST declared in pubspec.yaml.
    flutter:
       assets:
          - locale/     # for multiple languages
  • Initializes [Translations] with supported locales and optional parameters.
    List<String> localesSupported = [Localization.en_US, Localization.zh_Hans, Localization.fr_CA, Localization.pt_BR];
    String localeSelected = Localization.zh_Hans;
    
    List<Map<String, dynamic>> formatted = Translations.supported(localesSupported, selected: localeSelected);
  • Add delegates (LocalizationsPlusDelegate and FallbackCupertinoLocalizationsDelegate) to localizationsDelegates and assign supportedLocales with Translations.supportedLocales for WidgetsApp Created.
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          supportedLocales: Translations.supportedLocales,
          localizationsDelegates: const [
            LocalizationsPlusDelegate(),
            FallbackCupertinoLocalizationsDelegate()
            // ... more localization delegates
          ],
          home: const Home(),
        );
      }
    }
  • Retrieve locale JSON strings by [key]
    // 1. Uses sprintf-style ordered arguments for dynamic formatting.
    Translations.of(context).text("local_time_caption", DateTime.now());
    Translations.of(context).text("flight_broadcast_test", ["flutter_localizations_plus", "pub.flutter-io.cn"]);
    
    // 2. Fetches raw string in locale file
    Translations.of(context).text("welcome_tips");
    
  • Manually updates app's locale (e.g., from UI language settings page selections).
    String locale = Localization.fr_CA;
    await Translations.changeLanguage(locale);

Additional information #

Feel free to file an issue if you have any problem.

1
likes
0
points
49
downloads

Publisher

unverified uploader

Weekly Downloads

An enhanced Flutter localization solution that streamlines multilingual integration for seamless app development.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, sprintf

More

Packages that depend on flutter_localizations_plus