Skip to main content

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

Parser, validator and Dart code generator for l10n_plus translations.

example/example.md

Example #

pubspec.yaml:

dependencies:
  l10n_plus: ^0.1.0
  l10n_plus_flutter: ^0.1.0   # Flutter apps only

dev_dependencies:
  l10n_plus_generator: ^0.1.0

l10n_plus.yaml — one line is required:

base_locale: en

translations/en.json and translations/ru.json:

{
  "auth": { "login": { "title": "Log in", "subtitle": "Welcome back, {name}" } },
  "cart": "{count, plural, =0{Empty} one{# item} other{# items}}"
}
{
  "auth": { "login": { "title": "Войти", "subtitle": "С возвращением, {name}" } },
  "cart": "{count, plural, =0{Пусто} one{# товар} few{# товара} many{# товаров} other{# товара}}"
}

Generate, and again on every change:

dart run l10n_plus_generator generate --watch

Use it:

import 'generated/app_localizations.g.dart';

void main() {
  final t = AppLocalizations.forLocale(AppLocale.ru);
  print(t.auth.login.subtitle(name: 'Ада')); // С возвращением, Ада
  print(t.cart(count: 3));                   // 3 товара
}

A missing key, a wrong argument or a plural without its branches fails the build, not the app. In CI:

dart run l10n_plus_generator analyze

A complete Flutter app is in example/ of the repository.

0
likes
160
points
361
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Parser, validator and Dart code generator for l10n_plus translations.

Repository (GitHub)
View/report issues

Topics

#localization #i18n #l10n #translation #codegen

License

MIT (license)

Dependencies

args, dart_style, l10n_plus, path, source_span, yaml

More

Packages that depend on l10n_plus_generator