dart-lang/intl_translation

Name: intl_translation

Owner: Dart

Description: Message extraction and code generation from translated messages for the intl package

Created: 2016-09-02 17:59:40.0

Updated: 2018-05-23 02:04:41.0

Pushed: 2018-05-24 09:52:00.0

Homepage: https://pub.dartlang.org/packages/intl_translation

Size: 124

Language: Dart

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Intl_translation

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.

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";
  ...
  initializeMessages("dk").then(printSomeMessages);

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.