Flutter Localization Tool
This project is a Dart-based localization tool tailored for Flutter Localization SaaS users. It handles ARB files and generates the corresponding Dart localization classes efficiently.
Features
- Parses ARB localization files
- Generates strongly typed localization classes for Flutter
- Supports flavor-based localization structure
- Git integration (GitHub, GitLab, Bitbucket)
Installation
- Activate the package globally:
dart pub global activate flutter_localisation
- Ensure the Dart bin directory is in your system’s PATH:
Add the following to your shell config file (e.g., .bashrc
or .zshrc
):
export PATH="$PATH":"$HOME/.pub-cache/bin"
Project Setup
Before generating localization files:
- Link your project to a Git repository (GitHub, GitLab, or Bitbucket).
- Clone the ARB file repository into your Flutter project directory.
Usage
Generate Localization Files
Run the following command to generate localization code for a specific flavor:
flutter_localisation [arb_directory] [flavor]
Example:
flutter_localisation myArbs usa
Flutter Project Setup
- Add dependencies:
flutter pub add flutter_localizations --sdk=flutter
flutter pub add intl:any
- Enable code generation in
pubspec.yaml
:
flutter:
generate: true
Integrate in Your Flutter App
In your MaterialApp
widget:
MaterialApp(
title: 'Localizations Sample App',
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
)
Example usage in AppBar:
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.helloWorld),
),