localization_generator 1.0.0-dev.1 copy "localization_generator: ^1.0.0-dev.1" to clipboard
localization_generator: ^1.0.0-dev.1 copied to clipboard

outdated

A flutter project that used to generate the localization file to help localization easier.

localization_generator #

A command tool to generate localization from JSON file.

Dart CI

Getting Start #

Add to your pubspec.yaml.

dev_dependencies:
  localization_generator: <last_version>

Add translation files to a folder.

l10n
  +- {languageCode}.json
  +- {languageCode}-{countryCode}.json
  +- {languageCode}-{scriptCode}.json

Run the following command.

flutter pub run localization_generator --output=./l10n --input=./l10n

Configuration app.

// Import the generated localization file.
import 'l10n/localization.dart';

MaterialApp(
  onGenerateTitle: (context) {
    return Localized.of(context).hello(name: "my name");
  },
  theme: ThemeData(
    primarySwatch: Colors.blue,
  ),
  localizationsDelegates: [
    Localized.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate
  ],
  supportedLocales: Localized.delegate.supportedLocales,
  home: Builder(builder: (context) {
    return Column(
      children: [
        Text(Localized.of(context).hi),
        Text(Localized.of(context).price(currency: "TWD")),
        Text(Localized.of(context).gender(gender: "female")),
        Text(Localized.of(context).reply(count: 0)),
      ],
    );
  }),
);

Example project

MessageFormat #

The message pattern is follow the ICU MessageFormat.

Unsupport #

  • offset of plural
  • date
  • number
4
likes
0
pub points
28%
popularity

Publisher

unverified uploader

A flutter project that used to generate the localization file to help localization easier.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, intl, path

More

Packages that depend on localization_generator