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

A Flutter package for i18n using Sonnet

Sonnet #

Internationalization in Flutter sucks. Sonnet an make it suck less.

Quick Start #

  1. Add the package to your project:

    pubspec.yaml:

    dependencies:
      sonnet:
    
  2. Import the package, initialize and wrap your app in Sonnet:

    import 'package:sonnet/sonnet.dart';
      
    main() {
      // Get public key from https://dashboard.sonnet.international
      Sonnet.init(publicKey: '**************');
         
      runApp(
        Sonnet(
          builder: (locale) {
            return MaterialApp(
              title: 'Sonnet Demo',
              locale: locale,
              localizationsDelegates: Sonnet.localizationsDelegates,
              supportedLocales: Sonnet.supportedLocales,
              home: MyHomePage(),
            );
          },  
        ),
      );
    }
    
  3. Generate your translations:

    flutter pub global activate sonnet # (first-time only)
    flutter pub global run sonnet:gen
    

Change User Locale #

Sonnet will automatically detect the user's locale and update the app accordingly. You can also manually change the locale:

Sonnet.instance.changeLocale('fr');
0
likes
130
points
165
downloads

Publisher

verified publishersonnet.international

Weekly Downloads

A Flutter package for i18n using Sonnet

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

collection, flutter, intl, intl_generator, meta, path, shared_preferences, yaml

More

Packages that depend on sonnet