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.
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]
(https://code.google.com/p/arb/wiki/ApplicationResourceBundleSpecification)
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";
...
initializeMessages("dk").then(printSomeMessages);
Once the future returned from the initialization call returns, the message data is available.
Add this to your package's pubspec.yaml file:
dependencies:
intl_translation: ^0.17.0
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 flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:intl_translation/extract_messages.dart';
import 'package:intl_translation/generate_localized.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.17.3 | Feb 12, 2019 |
|
|
0.17.2 | Oct 1, 2018 |
|
|
0.17.1 | Sep 28, 2018 |
|
|
0.17.0 | Jul 17, 2018 |
|
|
0.16.8 | Jul 5, 2018 |
|
|
0.16.7 | May 17, 2018 |
|
|
0.16.6 | Apr 11, 2018 |
|
|
0.16.5 | Apr 10, 2018 |
|
|
0.16.4 | Mar 21, 2018 |
|
|
0.16.3 | Mar 12, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
98
|
Health:
Code health derived from static analysis.
[more]
|
93
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
90
|
Overall:
Weighted score of the above.
[more]
|
95
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, other
Platform components identified in package:
io
,isolate
.
Fix lib/src/intl_message.dart
. (-3.45 points)
Analysis of lib/src/intl_message.dart
reported 7 hints, including:
line 133 col 33: Use =
to separate a named parameter from its default value.
line 133 col 63: Use =
to separate a named parameter from its default value.
line 141 col 25: Use isNotEmpty
for Iterables and Maps.
line 439 col 33: Use =
to separate a named parameter from its default value.
line 439 col 63: Use =
to separate a named parameter from its default value.
Fix bin/extract_to_arb.dart
. (-1 points)
Analysis of bin/extract_to_arb.dart
reported 2 hints:
line 59 col 7: Use isEmpty instead of length
line 130 col 26: Use =
to separate a named parameter from its default value.
Fix bin/generate_from_arb.dart
. (-1 points)
Analysis of bin/generate_from_arb.dart
reported 2 hints:
line 79 col 7: Use isEmpty instead of length
line 79 col 32: Use isEmpty instead of length
Fix additional 4 files with analysis or formatting issues. (-2 points)
Additional issues in the following files:
bin/make_examples_const.dart
(1 hint)bin/rewrite_intl_messages.dart
(1 hint)lib/generate_localized.dart
(1 hint)lib/src/message_rewriter.dart
(1 hint)Maintain an example. (-10 points)
Create a short demo in the example/
directory to show how to use this package.
Common filename patterns include main.dart
, example.dart
, and intl_translation.dart
. Packages with multiple examples should provide example/README.md
.
For more information see the pub package layout conventions.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.33.0 <3.0.0 | ||
analyzer | >=0.32.1 <0.33.0 | 0.32.6 | 0.35.1 |
args | >=0.12.1 <2.0.0 | 1.5.1 | |
dart_style | ^1.0.0 | 1.1.3 | 1.2.3 |
intl | >=0.15.3 <0.16.0 | 0.15.7 | |
path | >=0.9.0 <2.0.0 | 1.6.2 | |
petitparser | >=1.1.3 <2.0.0 | 1.7.7 | 2.1.1 |
Transitive dependencies | |||
async | 2.0.8 | ||
charcode | 1.1.2 | ||
collection | 1.14.11 | ||
convert | 2.1.1 | ||
crypto | 2.0.6 | ||
csslib | 0.14.6 | ||
front_end | 0.1.4+2 | 0.1.11 | |
glob | 1.1.7 | ||
html | 0.13.3+3 | ||
kernel | 0.3.4+2 | 0.3.11 | |
logging | 0.11.3+2 | ||
matcher | 0.12.4 | ||
meta | 1.1.7 | ||
package_config | 1.0.5 | ||
plugin | 0.2.0+3 | ||
source_span | 1.5.4 | ||
stack_trace | 1.9.3 | ||
string_scanner | 1.0.4 | ||
term_glyph | 1.1.0 | ||
typed_data | 1.1.6 | ||
utf | 0.9.0+5 | ||
watcher | 0.9.7+10 | ||
yaml | 2.1.15 | ||
Dev dependencies | |||
test | ^1.2.0 |