fluent_localization 1.6.0 copy "fluent_localization: ^1.6.0" to clipboard
fluent_localization: ^1.6.0 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.6.0

Add language folder to Flutter assets #

flutter:
    assets:
        - "assets/languages/"

Create assets files #

// assets/languages/en.json
{
    "hello": "Hello {name}!",
    "title": "Welcome"
}

Build module #

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

Type-Safe Generation (NEW 🚀) #

To avoid using strings keys manually, you can generate type-safe keys using the built-in generator.

1. Run the generator #

Run this command in your project root:

fvm dart run fluent_localization:generate

This will create a file at lib/src/api/localization_keys.g.dart.

2. Use it in your code #

Import the generated file and use the context.loc extension:

// Simple key
Text(context.loc.title)

// Key with arguments
Text(context.loc.hello(name: 'John'))

Manual Usage #

If you prefer not to use the generator:

final hello = context.tr('hello', args: {'name': 'John'});

Example #

1
likes
0
points
401
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

fluent_localization_api, fluent_logger_api, fluent_sdk, flutter, flutter_localizations

More

Packages that depend on fluent_localization