intl_translation 0.16.4

  • Installing
  • Versions
  • 99


This package 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 extract_to_arb.dart program.

  pub run intl_translation:extract_to_arb --output-dir=target/directory
      my_program.dart more_of_my_program.dart

This will produce a file intl_messages.arb with the messages from all of these programs. an [ARB] ( format file which can be used for input to translation tools like Google Translator Toolkit The resulting translations can be used to generate a set of libraries using the generate_from_arb.dart program.

This expects to receive a series of files, one per locale.

pub run intl_translation:generate_from_arb --generated-file-prefix=<prefix>
    <my_dart_files> <translated_ARB_files>

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.

  import "my_prefix_messages_all.dart";

Once the future returned from the initialization call returns, the message data is available.


  • Update Intl compatibility requirements. This requires at least 0.15.3 of Intl, because the tests contain messages with the new "skip" parameter.


  • Fix - specify concrete type for generated map.


  • Handle fallback better when we provide translations for locale "xx" but initialize "xx_YY", initializing "xx". Previously we would do nothing.
  • Skip extracting messages that pass the 'skip' argument to Intl calls.
  • Move analyzer dependency up to 0.32.0


  • Add @@last_modified to extracted ARB files.
  • Handle @@locale in translated ARB files properly, and adds a --locale parameter to specify the locale.
  • Adds a --output-file parameter to extract_to_arb
  • Indent the output file for ARB for better readability.
  • A couple of tweaks to satisfy Flutter's default linter rules when run on the generated code.


  • BREAKING CHANGE: Require that the examples to message/plural/gender/select calls be const. DDC does not optimize non-const maps well, so it's a significant performance issue if these are non-const.
  • Added a utility to convert examples in calls to be const. See bin/make_examples_const.dart
  • Add a codegen_mode flag, which can be either release or debug. In release mode a missing translation throws an exception, in debug mode it returns the original text, which was the previous behavior.
  • Add support for generating translated messages as JSON rather than methods. This can significantly improve dart2js compile times for applications with many translations. The JSON is a literal string in the deferred library, so usage doesn't change at all.


  • Change non-transformer message rewriting to preserve the original message as much as possible. Adds --useStringSubstitution command-line arg.
  • Change non-transformer message rewriting to allow multiple input files to be specified on the command line. Adds --replace flag to ignore --output option and just replace files.
  • Make non-transformer message rewriting also run dartfmt on the output.
  • Make message extraction more robust: error message instead of stack trace when an Intl call is made outside a method, when a prefixed expression is used in an interpolation, and when a non-required example Map is not a literal.
  • Make message extraction more robust: if parsing triggers an exception then report it as an error instead of exiting.
  • Move barback to being a normal rather than a dev dependency.
  • Add a check for invalid select keywords.
  • Added a post-message construction validate, moved IntlMessageExtractionException into intl_message.dart
  • Make use of analyzer's new AstFactory class (requires analyzer version 0.29.1).
  • Fix error in transformer, pass the path instead of the asset id.
  • Prefer an explicit =0/=1/=2 to a ZERO/ONE/TWO if both are present. We don't distinguish the two as Intl.message arguments, we just have the "one" parameter, which we confusingly write out as =1. Tools interpret these differently, and in particular, a ONE clause is used for the zero case if there's no explicit zero. Translation tools may implement this by filling in both ZERO and ONE values with the OTHER clause when there's no ZERO provided, resulting in a translation with both =1 and ONE clauses which are different. We should prefer the explicit =1 in that case. In future we may distinguish the different forms, but that would probably break existing translations.
  • Switch to using package:test
  • Give a more specific type in the generated code to keep lints happy.


  • Split message extraction and code generation out into a separate package. Versioned to match the corresponding Intl version.

1. Depend on it

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

  intl_translation: "^0.16.4"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:intl_translation/extract_messages.dart';

import 'package:intl_translation/generate_localized.dart';

import 'package:intl_translation/transformer.dart';
Version Uploaded Documentation Archive
0.16.4 Mar 21, 2018 Go to the documentation of intl_translation 0.16.4 Download intl_translation 0.16.4 archive
0.16.3 Mar 12, 2018 Go to the documentation of intl_translation 0.16.3 Download intl_translation 0.16.3 archive
0.16.2 Mar 9, 2018 Go to the documentation of intl_translation 0.16.2 Download intl_translation 0.16.2 archive
0.16.1 Nov 23, 2017 Go to the documentation of intl_translation 0.16.1 Download intl_translation 0.16.1 archive
0.16.0 Oct 19, 2017 Go to the documentation of intl_translation 0.16.0 Download intl_translation 0.16.0 archive
0.15.0 Jun 5, 2017 Go to the documentation of intl_translation 0.15.0 Download intl_translation 0.15.0 archive
0.14.0+1 Sep 6, 2016 failed Download intl_translation 0.14.0+1 archive
0.14.0 Sep 2, 2016 failed Download intl_translation 0.14.0 archive


We analyzed this package on Mar 21, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.32.0
  • pana: 0.10.3


Describes how popular the package is relative to other packages. [more]
98 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Platform components identified in package: build, io.


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use intl_translation.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.12.0 <2.0.0
analyzer >=0.29.1 <0.32.0 0.31.2-alpha.0
args >=0.12.1 <2.0.0 1.4.1
barback ^0.15.2 0.15.2+14
dart_style ^1.0.0 1.0.10
intl >=0.15.3 <0.16.0 0.15.4
path >=0.9.0 <2.0.0 1.5.1
petitparser >=1.1.3 <2.0.0 1.7.6
Transitive dependencies
async 2.0.6
charcode 1.1.1
cli_util 0.1.2+1
collection 1.14.9
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
front_end 0.1.0-alpha.10
glob 1.1.5
html 0.13.3
isolate 1.1.0
kernel 0.3.0-alpha.10
logging 0.11.3+1
matcher 0.12.1+4
meta 1.1.2
package_config 1.0.3
plugin 0.2.0+2
pool 1.3.4
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
yaml 2.1.13
Dev dependencies
test >=0.10.0 <0.13.0