Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Issue 12733003: Adds facilities for extracting Intl.message calls and generating code from translations (Closed)

Created:
7 years, 9 months ago by Alan Knight
Modified:
7 years, 9 months ago
Reviewers:
Emily Fortuna
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Adds facilities for extracting Intl.message calls and generating code from translations This adds both general libraries for extracting messages and generating translations and scripts for using them with a trivial translation format. It removes the previous mechanism in message_lookup_local that relied on mirrors and traversing libraries in favor of one with a more explicit lookup by library that's consistent with the generated code. It also changes the code in basic_example to use that. It also includes a couple of other changes. It now uses pathos for path manipulation, and the data_directory.dart hack for running tests from multiple different places was cleaned up and made more general. In addition, Intl.message now returns a string rather than a Future, which was changed as part of the libv2 integration. This version does not yet support the plural syntax, as it disallows any interpolations that aren't just replacing a variable name. It also doesn't support named arguments to functions containing Intl.message, and it doesn't yet have a mechanism for designating sections of a text as not being subject to translation. Finally, it relies on analyzer-experimental, which has a different name in the repository and in pub. So this version will run in the repository but will not run if used from pub. Bug 9071 asks for the names to be made consistent. Committed: https://code.google.com/p/dart/source/detail?r=20047

Patch Set 1 #

Total comments: 61

Patch Set 2 : Fixes from review comments, also made tests more robust, removed scheduled_test dependency #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+1604 lines, -283 lines) Patch
M pkg/intl/example/basic/basic_example.dart View 4 chunks +15 lines, -14 lines 0 comments Download
M pkg/intl/example/basic/messages_all.dart View 1 chunk +28 lines, -4 lines 0 comments Download
M pkg/intl/example/basic/messages_de.dart View 1 chunk +14 lines, -6 lines 0 comments Download
M pkg/intl/example/basic/messages_th_th.dart View 1 chunk +12 lines, -6 lines 0 comments Download
M pkg/intl/example/basic/pubspec.yaml View 1 chunk +2 lines, -7 lines 0 comments Download
M pkg/intl/lib/date_symbol_data_file.dart View 2 chunks +4 lines, -4 lines 0 comments Download
A pkg/intl/lib/extract_messages.dart View 1 1 chunk +332 lines, -0 lines 0 comments Download
A pkg/intl/lib/generate_localized.dart View 1 1 chunk +170 lines, -0 lines 0 comments Download
M pkg/intl/lib/intl.dart View 1 3 chunks +9 lines, -3 lines 2 comments Download
A pkg/intl/lib/message_lookup_by_library.dart View 1 1 chunk +140 lines, -0 lines 0 comments Download
M pkg/intl/lib/message_lookup_local.dart View 1 1 chunk +0 lines, -123 lines 0 comments Download
M pkg/intl/lib/src/file_data_reader.dart View 2 chunks +2 lines, -1 line 0 comments Download
M pkg/intl/lib/src/intl_helpers.dart View 1 2 chunks +7 lines, -1 line 0 comments Download
A pkg/intl/lib/src/intl_message.dart View 1 1 chunk +169 lines, -0 lines 0 comments Download
M pkg/intl/pubspec.yaml View 1 1 chunk +5 lines, -7 lines 0 comments Download
M pkg/intl/test/data_directory.dart View 1 1 chunk +32 lines, -10 lines 0 comments Download
M pkg/intl/test/intl_message_basic_example_test.dart View 1 1 chunk +0 lines, -2 lines 0 comments Download
M pkg/intl/test/intl_message_test.dart View 1 1 chunk +0 lines, -93 lines 0 comments Download
A pkg/intl/test/message_extraction/extract_to_json.dart View 1 1 chunk +67 lines, -0 lines 0 comments Download
A pkg/intl/test/message_extraction/find_output_directory.dart View 1 1 chunk +19 lines, -0 lines 0 comments Download
A pkg/intl/test/message_extraction/generate_from_json.dart View 1 1 chunk +97 lines, -0 lines 0 comments Download
A pkg/intl/test/message_extraction/make_hardcoded_translation.dart View 1 1 chunk +105 lines, -0 lines 0 comments Download
A pkg/intl/test/message_extraction/message_extraction_test.dart View 1 1 chunk +208 lines, -0 lines 2 comments Download
A pkg/intl/test/message_extraction/part_of_sample_with_messages.dart View 1 1 chunk +34 lines, -0 lines 0 comments Download
A pkg/intl/test/message_extraction/sample_with_messages.dart View 1 1 chunk +132 lines, -0 lines 0 comments Download
M pkg/pkg.status View 1 2 chunks +1 line, -2 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Alan Knight
7 years, 9 months ago (2013-03-12 20:00:29 UTC) #1
Emily Fortuna
https://codereview.chromium.org/12733003/diff/1/pkg/intl/lib/extract_messages.dart File pkg/intl/lib/extract_messages.dart (right): https://codereview.chromium.org/12733003/diff/1/pkg/intl/lib/extract_messages.dart#newcode15 pkg/intl/lib/extract_messages.dart:15: * break if there are changes to the API ...
7 years, 9 months ago (2013-03-13 18:54:43 UTC) #2
Alan Knight
PTAL Also made changes to make the tests run more reliably when package-root is set ...
7 years, 9 months ago (2013-03-14 17:49:04 UTC) #3
Emily Fortuna
lgtm with the adjustments mentioned below! https://codereview.chromium.org/12733003/diff/1/pkg/intl/lib/intl.dart File pkg/intl/lib/intl.dart (right): https://codereview.chromium.org/12733003/diff/1/pkg/intl/lib/intl.dart#newcode50 pkg/intl/lib/intl.dart:50: * msg(num_people, place) ...
7 years, 9 months ago (2013-03-14 19:45:00 UTC) #4
Alan Knight
Committed patchset #2 manually as r20047 (presubmit successful).
7 years, 9 months ago (2013-03-14 20:49:42 UTC) #5
Alan Knight
7 years, 9 months ago (2013-03-14 20:50:04 UTC) #6
Message was sent while issue was closed.
https://codereview.chromium.org/12733003/diff/1/pkg/intl/lib/message_lookup_b...
File pkg/intl/lib/message_lookup_by_library.dart (right):

https://codereview.chromium.org/12733003/diff/1/pkg/intl/lib/message_lookup_b...
pkg/intl/lib/message_lookup_by_library.dart:29: // For this usage, if the locale
doesn't exist for messages, just return
On 2013/03/14 19:45:00, Emily Fortuna wrote:
> On 2013/03/14 17:49:05, Alan Knight wrote:
> > On 2013/03/13 18:54:43, Emily Fortuna wrote:
> > > random indentation?
> > Not random, I put each argument to the function on a separate line, and
> indented
> > them four spaces, which seemed to be one of the permitted things in the
style
> > guide. And I put the start of the function call on a separate line because
it
> > seemed clearer to have it indented less than its arguments. But I'm not
fussy
> > about the formatting. How would you prefer it to look?
> 
> No, that's totally fine. I was complaining that lines 41-47 seem to all be
> indented two extra spaces for no clear reason.

Doh! Done.

https://codereview.chromium.org/12733003/diff/12001/pkg/intl/lib/intl.dart
File pkg/intl/lib/intl.dart (right):

https://codereview.chromium.org/12733003/diff/12001/pkg/intl/lib/intl.dart#ne...
pkg/intl/lib/intl.dart:62: * Calling `msg(2, 'Athens'});` would
On 2013/03/14 19:45:00, Emily Fortuna wrote:
> nit: remove }

Done.

https://codereview.chromium.org/12733003/diff/12001/pkg/intl/test/message_ext...
File pkg/intl/test/message_extraction/message_extraction_test.dart (right):

https://codereview.chromium.org/12733003/diff/12001/pkg/intl/test/message_ext...
pkg/intl/test/message_extraction/message_extraction_test.dart:51:
.then(expectAsync1((result) => generateTranslationFiles(result)
On 2013/03/14 19:45:00, Emily Fortuna wrote:
> a handy new feature for our unittesting library went in dealing with futures.
> The test will pass if the future completes successfully. So you can rewrite
this
> nested thing like this:
> 
> test("Test round trip message generation, printing, and ", () {
>   deleteGeneratedFiles();
>   return extractMessages(null);
> }.then((result) {
>   return generateTranslationFiles(result);
> }.then((result) {
>   return generateCodeFromTranslation(result);
> });
> 
> etc, and then you don't have to do the onError, because the unittest future
> handling will propagate the errors.

Nice.

Powered by Google App Engine
This is Rietveld 408576698