dartpub.dev DartNative · beta
plugins / dartnative_intl
di

dartnative_intl

v1.0.1 dartpub Free

ARB localisation code generator

The DartNative localisation code generator — a drop-in replacement for `intl_utils` that turns ARB files into pure-DartNative l10n code (`S.of(context)`, `S.delegate`) using the same `flutter_intl:` config. One command, no external SDK.

by DartNative/dartnative_intl · DartNative ≥ 3.0 · updated 1 day ago
Install
Free
pubspec.yaml
dependencies:
  dartnative_intl: ^1.0.1
Weekly installs
45
Active apps
14
Rating
0.0 · 0
Open issues
0

dartnative_intl

ARB-to-Dart localisation code generator for DartNative apps — a drop-in replacement for intl_utils. One command, same config, generated code that's pure DartNative.

Why you'll like it

  • Pure DartNative output — generated files import dartnative; your l10n layer has no external SDK dependency.
  • Same config — the flutter_intl: block in pubspec.yaml works exactly as with intl_utils; nothing to learn.
  • Same generated APIS.of(context) and S.delegate are identical (supportedLocales lives on the delegate: S.delegate.supportedLocales); existing app code needs no changes beyond swapping the dependency.
  • One commanddn run-tool dartnative_intl:generate, the DartNative equivalent of intl_utils' own generate step.

Highlights

  • dn run-tool dartnative_intl:generate — reads your ARB files and generates the full l10n class tree.
  • Locale, LocalizationsDelegate, Localizations — pure-Dart runtime shims included so generated code compiles with no extra dependencies.
  • Localizely support — optional download step pulls ARBs from Localizely before generating (same as upstream).

Install

dependencies:
  dartnative_intl: ^1.0.0   # from dartpub.dev
dn pub get

Configure in pubspec.yaml (same keys as intl_utils):

flutter_intl:
  enabled: true
  arb_dir: lib/l10n
  output_dir: lib/generated
  main_locale: en

Quick look

Add your ARB files:

lib/l10n/intl_en.arb
lib/l10n/intl_pt.arb

Run the generator:

dn run-tool dartnative_intl:generate

Use the generated class in your app:

import 'package:dartnative_intl/dartnative_intl.dart';

// Register the resolver once at startup, before runApp()
Localizations.setResolver((context, type) => myLocalizationLookup(context, type));

// Then anywhere in your widget tree
final label = S.of(context).welcomeMessage;

Load a locale (there is no localizationsDelegates list to wire up — the resolver above is the whole hookup):

await S.delegate.load(const Locale('fr'));

// The locales the generated delegate knows about:
final locales = S.delegate.supportedLocales;

Credits & license

Adapted from intl_utils (MIT), reworked to use DartNative imports.

Distributed via dartpub.dev — file issues on the plugin's page.