fluent_localization 1.1.1 copy "fluent_localization: ^1.1.1" to clipboard
fluent_localization: ^1.1.1 copied to clipboard

Package that allows you to set up and use translations in an easy and quick way

fluent_localization #

Package that allows you to set up and use translations in an easy and quick way

Getting Started #

Add dependencies #

fluent_localization: ^1.1.1

Add language folder to Flutter assets #

flutter:
    assets:
        - "assets/languages/"

Create assets files #

assets/
    languages/
        en.json
        es.json

Build module #

void main() async {
  await Fluent.build([
    LocalizationModule(),
  ]);
  runApp(App());
}

Use it #

class App extends StatelessWidget {
    const App({super.key});

    @override
    Widget build(BuildContext context) {
        // Define your supported locales
        final locales = [
            Locale("es"),
            Locale("en"),
        ];
        // Get localization delegates
        final delegates = Fluent.get<LocalizationApi>().getDelegates(locales);
        
        return MaterialApp(
            title: 'Fluent Localization Demo',
            localizationsDelegates: delegates,
            supportedLocales: locales,
            home: Scaffold(
                body: Builder(
                    builder: (context) {
                        final hello = context.tl('hello');
                        return Center(
                            child: Text(hello),
                        );
                    },
                ),
            ),
        );
    }
}

Example #

0
likes
160
pub points
49%
popularity

Publisher

unverified uploader

Package that allows you to set up and use translations in an easy and quick way

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

fluent_localization_api, fluent_sdk, flutter, flutter_localizations

More

Packages that depend on fluent_localization