Provides message extraction and code generation from translated messages for the intl package. It's a separate package so as to not require a dependency on analyzer for all users.
Extracting And Using Translated Messages
When your program contains messages that need translation, these must be extracted from the program source, sent to human translators, and the results need to be incorporated.
To extract messages, run the
dart run intl_translation:extract_to_arb --output-dir=target/directory \
This supports wildcards. For example, to extract messages from a series of files in path
lib/**/*.dart, you can run
dart run intl_translation:extract_to_arb --output-dir=target/directory
This will produce a file
intl_messages.arb with the messages from all of these
programs. This is an ARB format file which can be used for input to
translation tools like Localizely or Lyrebird. The resulting translations can
be used to generate a set of libraries using the
This expects to receive a series of files, one per locale.
dart run intl_translation:generate_from_arb --generated-file-prefix=<prefix> \
This will generate Dart libraries, one per locale, which contain the translated
versions. Your Dart libraries can import the primary file, named
<prefix>messages_all.dart, and then call the initialization for a specific
locale. Once that's done, any Intl.message calls made in the
context of that locale will automatically print the translated version instead
of the original.
Future returned from the initialization call completes, the message
data is available.
- This is for use in extracting messages from a Dart program
using the Intl.message() mechanism and writing them to a file for
translation. This provides only the stub of a mechanism, because it
doesn't define how the file should be written. It provides an
IntlMessageclass that holds the extracted data and
parseFilemethods which can extract messages that conform to the expected pattern: (parameters) => Intl.message("Message $parameters", desc: ...); It uses the analyzer package to do the parsing, so may break if there are changes to the API that it provides. An example can be found in test/message_extraction/extract_to_json.dart
- This provides utilities for generating localized versions of messages. It does not stand alone, but expects to be given TranslatedMessage objects and generate code for a particular locale based on them.