intl_translation_format

The package intl_translation_format provides the tools needed to support a new translation format to work with the intl_translation package:

  • Message extraction from Dart code
  • Code generation from translated messages
  • New formats can be added without modifying this package, but it includes the ARB and XLIFF formats by default.

To learn more read the next section Getting Started and the Example project.

Current supported formats:

Getting started

1. Add package

Add this to your package's pubspec.yaml file:

dev_dependencies:
  intl_translation_format: [current version]

2. Add messages

Create your messages using the intl package

 String continueMessage() => Intl.message(
      'Hit any key to continue',
      name: 'continueMessage');

3. Export messages

Run the following command to export the messages to the desired format:

pub run intl_translation_format:extract 
    lib/main.dart --output-dir lib/l10n/ --format arb

4. Translate messages

Translate the messages manually or with a translation tool

5. Generate translations

Run the following command to generate the code from translation messages:

pub run intl_translation_format:generate 
    --project-name intl_messages
    --output-dir lib/l10n/  
    --format arb
    lib/main.dart 
    lib/l10n/arb/intl_messages_en.arb 
    lib/l10n/arb/intl_messages_es.arb   

Implement a new translation file format

TBD

Libraries

extract
format_test
generate
A main program that takes as input a source Dart file and a number of ARB files representing translations of messages from the corresponding Dart file. See extract_to_arb.dart and make_hardcoded_translation.dart. [...]
intl_translation_format
mock_file
test_utils
testers