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

Side by Side Diff: components/translate/core/browser/translate_manager.cc

Issue 2802613004: fix target language issue under three locales (Hebrew[iw->he], Fillipion[tl->fil], and Nowreign[no-… (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/translate/core/browser/translate_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/translate/core/browser/translate_manager.h" 5 #include "components/translate/core/browser/translate_manager.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // If there are no override. 507 // If there are no override.
508 if (language.empty()) { 508 if (language.empty()) {
509 // Get the language from ULP. 509 // Get the language from ULP.
510 language = TranslateManager::GetTargetLanguageFromULP(prefs); 510 language = TranslateManager::GetTargetLanguageFromULP(prefs);
511 if (!language.empty()) 511 if (!language.empty())
512 return language; 512 return language;
513 513
514 // Get the browser's user interface language. 514 // Get the browser's user interface language.
515 language = TranslateDownloadManager::GetLanguageCode( 515 language = TranslateDownloadManager::GetLanguageCode(
516 TranslateDownloadManager::GetInstance()->application_locale()); 516 TranslateDownloadManager::GetInstance()->application_locale());
517 // Map 'he', 'nb', 'fil' back to 'iw', 'no', 'tl'
518 translate::ToTranslateLanguageSynonym(&language);
jungshik at Google 2017/04/11 18:45:32 Shouldn't Google Translate API take care of this i
517 } 519 }
518 if (TranslateDownloadManager::IsSupportedLanguage(language)) 520 if (TranslateDownloadManager::IsSupportedLanguage(language))
519 return language; 521 return language;
520 522
521 // Will translate to the first supported language on the Accepted Language 523 // Will translate to the first supported language on the Accepted Language
522 // list or not at all if no such candidate exists. 524 // list or not at all if no such candidate exists.
523 std::vector<std::string> accept_languages_list; 525 std::vector<std::string> accept_languages_list;
524 prefs->GetLanguageList(&accept_languages_list); 526 prefs->GetLanguageList(&accept_languages_list);
525 for (const auto& lang : accept_languages_list) { 527 for (const auto& lang : accept_languages_list) {
526 std::string lang_code = TranslateDownloadManager::GetLanguageCode(lang); 528 std::string lang_code = TranslateDownloadManager::GetLanguageCode(lang);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 void TranslateManager::RecordTranslateEvent(int event_type) { 605 void TranslateManager::RecordTranslateEvent(int event_type) {
604 DCHECK(metrics::TranslateEventProto::EventType_IsValid(event_type)); 606 DCHECK(metrics::TranslateEventProto::EventType_IsValid(event_type));
605 translate_event_->set_event_type( 607 translate_event_->set_event_type(
606 static_cast<metrics::TranslateEventProto::EventType>(event_type)); 608 static_cast<metrics::TranslateEventProto::EventType>(event_type));
607 translate_event_->set_event_timestamp_sec( 609 translate_event_->set_event_timestamp_sec(
608 (base::TimeTicks::Now() - base::TimeTicks()).InSeconds()); 610 (base::TimeTicks::Now() - base::TimeTicks()).InSeconds());
609 translate_ranker_->AddTranslateEvent(*translate_event_); 611 translate_ranker_->AddTranslateEvent(*translate_event_);
610 } 612 }
611 613
612 } // namespace translate 614 } // namespace translate
OLDNEW
« no previous file with comments | « no previous file | components/translate/core/browser/translate_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698