flutter
The preset for flutter_i18n. It reads JSON and YAML assets, FlutterI18n.translate and the I18nText widgets in Dart.
The flutter preset supports flutter_i18n.
Detection
The preset applies when pubspec.yaml has the dependency flutter_i18n.
x18n.config.ts
import { flutter } from '@x18n/cli/presets'
import { defineConfig } from '@x18n/core'
export default defineConfig({
presets: [flutter()],
})Locale files
If your config has no resources, the preset uses assets/flutter_i18n/{locale}.{ext} and assets/i18n/{locale}.{ext}.
Supported syntax
In Dart files, the preset reads FlutterI18n.translate, FlutterI18n.plural, I18nText and I18nPlural:
lib/main.dart
Text(FlutterI18n.translate(context, "title"));
I18nText("greet");These usages are title and greet.
Placeholders
Braces: {name}.
Extraction templates
| Kinds | Template |
|---|---|
| any | FlutterI18n.translate(context, '{key}') |