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

Issue 552216: This CL makes the TranslationService class send the text to be translated to ... (Closed)

Created:
10 years, 10 months ago by jcampan
Modified:
9 years, 7 months ago
CC:
chromium-reviews, brettw+cc_chromium.org, darin (slow to review), jam, ben+cc_chromium.org, jeremy
Visibility:
Public.

Description

This CL makes the TranslationService class send the text to be translated to the translation server. It groups requests as to limit the number of requests sent to the server. Also this CL adds a flag to automatically turn on translation on pages that are not in the language Chrome is configured in. BUG=None TEST=Run the unit-tests. Add the --auto-translate flag then navigate to pages in a language which is not the language Chrome is configured. They should get translated. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=37479

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 58

Patch Set 3 : '' #

Patch Set 4 : '' #

Total comments: 12

Patch Set 5 : '' #

Total comments: 15
Unified diffs Side-by-side diffs Delta from patch set Stats (+1218 lines, -33 lines) Patch
M chrome/browser/net/test_url_fetcher_factory.h View 1 2 2 chunks +4 lines, -0 lines 0 comments Download
M chrome/browser/net/url_fetcher.h View 1 2 2 chunks +5 lines, -0 lines 0 comments Download
M chrome/browser/net/url_fetcher.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/renderer_host/render_process_host.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/renderer_host/render_view_host.h View 1 1 chunk +6 lines, -0 lines 0 comments Download
M chrome/browser/renderer_host/render_view_host.cc View 1 1 chunk +7 lines, -0 lines 0 comments Download
M chrome/browser/renderer_host/resource_message_filter.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/renderer_host/translation_service.h View 1 2 3 4 1 chunk +132 lines, -8 lines 4 comments Download
chrome/browser/renderer_host/translation_service.cc View 1 2 3 4 1 chunk +532 lines, -14 lines 8 comments Download
A chrome/browser/renderer_host/translation_service_unittest.cc View 1 2 1 chunk +458 lines, -0 lines 2 comments Download
M chrome/browser/tab_contents/tab_contents.cc View 1 2 2 chunks +14 lines, -0 lines 1 comment Download
chrome/chrome_tests.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/chrome_switches.h View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/chrome_switches.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/common/render_messages.h View 4 chunks +7 lines, -0 lines 0 comments Download
chrome/common/render_messages_internal.h View 1 1 chunk +9 lines, -0 lines 0 comments Download
M chrome/renderer/render_view.h View 1 2 2 chunks +12 lines, -3 lines 0 comments Download
M chrome/renderer/render_view.cc View 1 2 3 2 chunks +14 lines, -5 lines 0 comments Download
M chrome/renderer/translate/page_translator.cc View 1 3 chunks +5 lines, -1 line 0 comments Download
M chrome/renderer/translate/text_translator_impl.cc View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
jcampan
Jungshik, This is a new CL based on the previous CL you reviewed: http://codereview.chromium.org/464054/show Sorry ...
10 years, 10 months ago (2010-01-28 19:17:24 UTC) #1
jcampan
Adding Scott as well to the list of reviewers.
10 years, 10 months ago (2010-01-28 19:19:59 UTC) #2
Paweł Hajdan Jr.
Drive-by with minor test-related comments. http://codereview.chromium.org/552216/diff/2001/2007 File chrome/browser/renderer_host/translation_service_unittest.cc (right): http://codereview.chromium.org/552216/diff/2001/2007#newcode42 chrome/browser/renderer_host/translation_service_unittest.cc:42: STLDeleteContainerPointers(messages_.begin(), messages_.end()); nit: May ...
10 years, 10 months ago (2010-01-28 19:43:07 UTC) #3
sky
http://codereview.chromium.org/552216/diff/2001/2008 File chrome/browser/renderer_host/translation_service.cc (right): http://codereview.chromium.org/552216/diff/2001/2008#newcode31 chrome/browser/renderer_host/translation_service.cc:31: const char* locale_language; Can you document what they two ...
10 years, 10 months ago (2010-01-28 20:51:09 UTC) #4
jcampan
New snapshot pushed. Thanks! http://codereview.chromium.org/552216/diff/2001/2008 File chrome/browser/renderer_host/translation_service.cc (right): http://codereview.chromium.org/552216/diff/2001/2008#newcode31 chrome/browser/renderer_host/translation_service.cc:31: const char* locale_language; On 2010/01/28 ...
10 years, 10 months ago (2010-01-28 23:08:54 UTC) #5
sky
http://codereview.chromium.org/552216/diff/4003/4010 File chrome/browser/renderer_host/translation_service.cc (right): http://codereview.chromium.org/552216/diff/4003/4010#newcode141 chrome/browser/renderer_host/translation_service.cc:141: // static nit: definition order should match that of ...
10 years, 10 months ago (2010-01-28 23:53:45 UTC) #6
jcampan
New snapshot uploaded. http://codereview.chromium.org/552216/diff/4003/4010 File chrome/browser/renderer_host/translation_service.cc (right): http://codereview.chromium.org/552216/diff/4003/4010#newcode141 chrome/browser/renderer_host/translation_service.cc:141: // static On 2010/01/28 23:53:45, sky ...
10 years, 10 months ago (2010-01-29 00:33:22 UTC) #7
sky
LGTM
10 years, 10 months ago (2010-01-29 00:42:24 UTC) #8
jungshik at Google
On finishing the review, I realized that it's submitted because my review was delayed for ...
10 years, 10 months ago (2010-01-30 01:27:17 UTC) #9
jcampan
10 years, 10 months ago (2010-01-30 01:31:21 UTC) #10
> On finishing the review, I realized that it's submitted because my review
> was
> delayed for which I'm sorry.
No pb, thanks for the review!
I'll create a new CL addressing these.

> Anyway, it's ok because it looks good except for one issue (missing mapping
> for
> pt-BR/pt-PT to pt) and some very minor nits. I guess, the missing mapping
> entries and a test involving non-ASCII text can be added in a follow-up.
>
>
> http://codereview.chromium.org/552216/diff/5023/2029
> File chrome/browser/renderer_host/translation_service.cc (right):
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode45
> chrome/browser/renderer_host/translation_service.cc:45: { "es-419", "es"
> },
> Chrome's UI languages for Brazillian Portuguese and Iberian Portuguese
> are 'pt-BR' and 'pt-PT'. However, CLD just returns 'pt'. So, both
> 'pt-PT' and 'pt-BR' have to be mapped to 'pt'.
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode275
> chrome/browser/renderer_host/translation_service.cc:275: std::string
> str;
> nit: wrapped_data?
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode293
> chrome/browser/renderer_host/translation_service.cc:293: string16 str16;
> nit: translated_text?
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode299
> chrome/browser/renderer_host/translation_service.cc:299: TextChunks
> text_chunks;
> nit: translated_chunks might be a better name.
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode309
> chrome/browser/renderer_host/translation_service.cc:309: ListValue* list
> = static_cast<ListValue*>(value.get());
> nit: translated_text_list?
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode319
> chrome/browser/renderer_host/translation_service.cc:319:
> TranslationService::TextChunks text_chunks;
> nit: translated_chunks might be a better name.
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode334
> chrome/browser/renderer_host/translation_service.cc:334: // API uses,
> but for the ones longer than 2 chars.
> Hmm, the input parameters for this function are the language code
> returned by CLD and the Chrome's UI locale code. However,
> kLocaleToCLDLanguage array (despite its name) is mapping the Chrome's UI
> locale code to the language code accepted by Google Translate. There are
> 3 different codes.
>
> The logic in this function is correct, but either we have to add more
> entries to the array (because CLD returns 'no', 'iw', 'tl' instead of
> 'nb', 'he', 'fil') or we have to change languages.h (in
> cld/...i18n/languages/....) to return  the correct language codes :
> 'nb', 'he', 'fil'. I think the latter is better because it's yet another
> step toward open-sourcing CLD (there's no reason to carry along a
> google3 legacy when CLD is open-sourced).
>
> The CLD also returns 'zh' instead of 'zh-CN'. It has to be taken care of
> as well. (we can call LanguageCodeWithDialect instead of LanguageCode
> for this).
>
> Ok. I just updated my existing CLD clean-up CL to do two things I'm
> suggesting here. If you're ok with the other aspect of that CL (which I
> asked you to review), you can leave alone this part and the array except
> that pt-BR and pt-PT have to be mapped to 'pt'.
>
> http://codereview.chromium.org/552216/diff/5023/2029#newcode432
> chrome/browser/renderer_host/translation_service.cc:432: void
> TranslationService::SplitTextChunks(const string16& translated_text,
> nit: SplitIntoTextChunks seems better.
>
> http://codereview.chromium.org/552216/diff/5023/2032
> File chrome/browser/renderer_host/translation_service.h (right):
>
> http://codereview.chromium.org/552216/diff/5023/2032#newcode24
> chrome/browser/renderer_host/translation_service.h:24: // There is one
> TranslationService is per renderer process.
> nit: is per ==> per
>
> http://codereview.chromium.org/552216/diff/5023/2032#newcode65
> chrome/browser/renderer_host/translation_service.h:65: // given the
> values 'en' and 'en-US'.
> A TODO comment about a future enhancement (either overloading the
> existing Accept-Language UI or a separate UI for translation languages)
> here (or in the implementation) may be nice to have.
>
> http://codereview.chromium.org/552216/diff/5023/2032#newcode110
> chrome/browser/renderer_host/translation_service.h:110: // Warning the
> request is deleted when this call returns.
> nit: A colon is necessary after 'Warning', isn't it?
>
> http://codereview.chromium.org/552216/diff/5023/2032#newcode131
> chrome/browser/renderer_host/translation_service.h:131: static void
> SplitTextChunks(const string16& translated_text,
> nit: SplitIntoTextChunks seems better.
>
> http://codereview.chromium.org/552216/diff/5023/2028
> File chrome/browser/renderer_host/translation_service_unittest.cc
> (right):
>
> http://codereview.chromium.org/552216/diff/5023/2028#newcode231
> chrome/browser/renderer_host/translation_service_unittest.cc:231:
> TEST_F(TranslationServiceTest, SimpleSuccessfulTranslation) {
> as a sanity check, adding one more case (e.g. en => ja) involving
> non-ASCII text would be nice.
>
> http://codereview.chromium.org/552216/diff/5023/2028#newcode405
> chrome/browser/renderer_host/translation_service_unittest.cc:405: //
> Send 2 small requests, than a big one.
> nit: than ==> then
>
> http://codereview.chromium.org/552216/diff/5023/2026
> File chrome/browser/tab_contents/tab_contents.cc (right):
>
> http://codereview.chromium.org/552216/diff/5023/2026#newcode1814
> chrome/browser/tab_contents/tab_contents.cc:1814: std::string locale =
> g_browser_process->GetApplicationLocale();
> nit: perhaps, s/locale/ui_language/ and s/language/page_language/ would
> be clearer.
>
> http://codereview.chromium.org/552216
>

Powered by Google App Engine
This is Rietveld 408576698