arb_gen 0.0.5 copy "arb_gen: ^0.0.5" to clipboard
arb_gen: ^0.0.5 copied to clipboard

Dart package designed to simplify the translation and localization process in Flutter projects using ARB (Application Resource Bundle) files.

Pub package GH: WiKi CI Pub likes GH: issues GH: PRs GH: last commit Maintenance GitHub Discussions style: lint License: MIT

ARB Gen #

ARB Gen is a powerful Dart package tailored for Flutter projects, streamlining the translation and localization processes through ARB (Application Resource Bundle) files. This package automates the generation of translated ARB files, providing a seamless experience for developers and allowing them to concentrate on the translation aspect. Key features include automatic translation from a base language to multiple target languages, effortless integration with Flutter projects, and a flexible configuration setup that accommodates customization through a configuration file or command line arguments. ARB Gen also supports dynamic updates, allowing Flutter apps to receive new translations without requiring manual intervention. Developers can easily install the package by adding a dependency to their pubspec.yaml file and running flutter pub get. With straightforward usage steps and clear integration instructions, ARB Gen enhances the localization workflow, making it efficient and developer-friendly.

![Alt text](assets/arb_gen-1706034100144.gif)

Features #

  • Automatic Translation: Translate your content from a base language to multiple target languages with ease.
  • Integration with Flutter: Easily integrate the generated translations into your Flutter project.
  • Flexible Configuration: Customize the translation process with a configuration file or command line arguments.
  • Dynamic Updates: Dynamically update your Flutter app with new translations without manual intervention.

Installation #

Add the following dependency to your pubspec.yaml file:

dev_dependencies:
  arb_gen:

Then, run:

flutter pub get

Usage #

1. Configuration #

Create a configuration file arb.gen/config.json. Here's an example configuration file:

{
  "translateTo": ["fr", "es"],
  "ignored": ["appName"],
  "pathToFile": "arb.gen/content.json",
  "outputFolder": "lib/l10n/",
  "arbName": "localization",
  "baseLanguage": "en",
  "translater": null,
  "apiKey":null,
  "allAtOnce": true
}

Note: by default we prefer google translator, this aproach dont need any API-key, if field translater it'lll the same as 'google' .

Output directory for all generated .arb files. Defaults to 'lib/l10n'.

s

Property Type Description
translateTo List Codes of languages for which localization is required.
preferredLanguage String? Preferred language code; if null, it defaults to the first language in translateTo.
baseLanguage String? Code of the original language used in the base file.
ignored List Keys from the card that don't need to be transferred. Usually, these are custom keys (e.g., the application name).
outputClass String? Name of the output class for localization. Defaults to class $L{}.
lDirName String Path to the local service folder. Defaults to /lib/$outPutFolder.
arbName String Name for .arb files; follows the pattern arbName_languageCode.arb.
translater ['deepl', 'yandex', 'google', 'azure', 'microsoft', 'openAI'] The name of the service to be translated. Defaults to Google Translator
apiKey String? API key for the translation service. Not required for Google Translator.
allAtOnce bool? Flag to generate all translations at once. Defaults to true.
pathToFile String Path to the original .arb/.json file. Defaults to 'arb.gen/content.json'.

2. Run ARB Gen #

Run the following command to execute the translation process:

dart run arb_gen

3. Integration with Flutter #

If allAtOnce is set to false in your configuration, follow these steps to integrate the generated translations into your Flutter project:

3.1 Update pubspec.yaml

flutter:
  generate: true

dependencies:
  flutter_localizations:
    sdk: flutter
  intl:

3.2 Create l10n.yaml

arb-dir: lib/l10n
template-arb-file: localization_en.arb
output-localization-file: app_localizations.dart

3.3 Run Flutter Pub Get

Run the following command to fetch the dependencies and generate the localized files:

flutter pub get

3.4 Move Generated Files Manually

Manually move the generated ARB files from the specified output folder (lib/l10n/ by default) to your project's localization folder.

mv generated_arb_files/* lib/l10n/

3.5 Updating the iOS app bundle

See the documentation on the website.

Translated example

DE FR EN ES

Maintainers #

4
likes
135
pub points
18%
popularity

Publisher

unverified uploader

Dart package designed to simplify the translation and localization process in Flutter projects using ARB (Application Resource Bundle) files.

Repository (GitHub)
View/report issues
Contributing

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

collection

More

Packages that depend on arb_gen