Babel

Babel

Translations management for Flutter apps

Pub Version Pub Publisher Pub Points

Build codecov Language License: MIT

Table of Contents

Getting started

babel-banner

Babel is a command-line interface (CLI) tool crafted to simplify the management of translations in Flutter applications.

This intuitive toolset allows you to:

  • List project’s translations

    Easily examine your project’s language resources, identifying existing, missing, or unused translations.

    Utilize the power of AnsiX to print reports in data grids, tree views, or JSON format. Additionally, you can export them to files for convenient reference.

  • Sort translations

    Keep your translation files organized for enhanced readability and maintainability, making it easier for you and your team to work with translations effectively.

  • Clean generated files and unused translations

    Optimize your project’s footprint by removing redundant or unused translation keys, ensuring a lean and efficient application build.

Babel is a valuable asset for Flutter developers looking to streamline their localization workflow. Its user-friendly interface provides essential functionalities to ensure your project’s internationalization process is seamless and efficient.

Disclaimer

Please note that Babel is specifically designed to work with Flutter’s official localization tools.

It is not compatible with or intended for use alongside other third-party packages for localization.

To ensure seamless functionality and optimal performance, we recommend utilizing Babel exclusively with Flutter’s official localization capabilities.

list-all-grid

How to use

Add as dependency

Use babel in a specific project by adding it as a dev dependency.

# Add Babel as a dev dependency in your pubspec.yaml
dart pub add -d babel

# Run babel
dart run babel [command] [arguments]

Activate globally

Activate babel globally in your device, so you can use it from any project and make sure you always use the latest version.

# Activate Babel from pub.dev
dart pub global activate babel

# Run babel
babel [command] [arguments]

Commands

Babel uses dart_cmder for the CLI interface.

Read the documentation for more information.

Base arguments

ArgumentAbbreviationHelpAllowed valuesDefaults to
--path-pThe root path of the project where the pubspec.yaml is..
--level-lDefine the level that will be used to filter log messages. none, verbose, debug, info, success, warning, error, fatalinfo
--logdir-dIf not null, then messages will be logged into the specified directory.null
--color,--no-color-cIf set to false, no colors will be printed in the console.true

List

ArgumentAbbreviationHelpAllowed valuesDefaults to
--mode-mDefines how the report will be displayed. grid, tree, jsongrid
--export-directory-eIf this field is not empty, it will be used to export the results.
  • Grid
list-all-grid
  • Tree
list-all-tree
  • JSON
list-all-json

All

List all translation keys of the project.

babel list all

Missing

List all missing translation keys of the project.

babel list missing

Unused

List all unused translation keys of the project.

babel list unused

Sort

Sorts the translation keys in the arb files of the project.

babel list sort

Clean

Unused translations

Deletes all unused translation keys.

ArgumentHelpDefaults to
--dry-runIf set to true, babel will return with error when unused translations are found in a project.false
babel list clean unused-translations

# You can use the `dry-run` flag argument in your CI/CD workflows 
# to ensure no unused translation keys exist in your Flutter project.
babel list clean unused-translations --dry-run

Generated files

Deletes all generated localization files.

babel list clean generated-files

Contribution

Check the contribution guide if you want to help with babel.

Changelog

Check the changelog to learn what’s new in babel.


You may also be interested in