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

Unified Diff: chrome/common/translate/language_detection_util.cc

Issue 25212002: Bug fix: Translate: CLD2 imcompatibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (rebasing) Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/translate/language_detection_util.cc
diff --git a/chrome/common/translate/language_detection_util.cc b/chrome/common/translate/language_detection_util.cc
index fdde055c3ee6742b8b01e92cdd0c39d2a2425fc5..f61331bc070a90881c1cb2a3dd1821e7909e2067 100644
--- a/chrome/common/translate/language_detection_util.cc
+++ b/chrome/common/translate/language_detection_util.cc
@@ -152,8 +152,19 @@ std::string DetermineTextLanguage(const base::string16& text,
#endif
#if !defined(CLD_VERSION) || CLD_VERSION==2
case 2:
+ // (1) CLD2's LanguageCode returns general Chinese 'zh' for
+ // CLD2::CHINESE, but Translate server doesn't accept it. This is
+ // converted to 'zh-CN' in the same way as CLD1's
+ // LanguageCodeWithDialects.
+ //
+ // (2) CLD2's LanguageCode returns zh-Hant instead of zh-TW for
+ // CLD2::CHINESE_T. This is technically more precise for the language
+ // code of traditional Chinese, while Translate server hasn't accepted
+ // zh-Hant yet.
if (cld_language == CLD2::CHINESE) {
language = "zh-CN";
+ } else if (cld_language == CLD2::CHINESE_T) {
+ language = "zh-TW";
} else {
language =
CLD2::LanguageCode(static_cast<CLD2::Language>(cld_language));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698