sonnet 0.1.0 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 #
-
Add the package to your project:
pubspec.yaml
:dependencies: sonnet:
-
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(), ); }, ), ); }
-
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');