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

Unified Diff: chrome/browser/translate/translate_prefs.cc

Issue 68823004: [Translate] Apply language synonyms to the target language (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | « chrome/browser/translate/translate_prefs.h ('k') | components/translate/common/translate_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/translate/translate_prefs.cc
diff --git a/chrome/browser/translate/translate_prefs.cc b/chrome/browser/translate/translate_prefs.cc
index df9e1b64104281c288a8b5a284a75573638da83b..2b5589abc776b91638aec654575dca5e6b3579f8 100644
--- a/chrome/browser/translate/translate_prefs.cc
+++ b/chrome/browser/translate/translate_prefs.cc
@@ -47,26 +47,6 @@ void GetBlacklistedLanguages(const PrefService* prefs,
}
}
-// Converts the language code for Translate. This removes the sub code (like
-// -US) except for Chinese, and converts the synonyms.
-// The same logic exists at language_options.js, and please keep consistensy
-// with the JavaScript file.
-std::string ConvertLangCodeForTranslation(const std::string &lang) {
- std::vector<std::string> tokens;
- base::SplitString(lang, '-', &tokens);
- if (tokens.size() < 1)
- return lang;
-
- std::string main_part = tokens[0];
-
- // Translate doesn't support General Chinese and the sub code is necessary.
- if (main_part == "zh")
- return lang;
-
- translate::ToTranslateLanguageSynonym(&main_part);
- return main_part;
-}
-
// Expands language codes to make these more suitable for Accept-Language.
// Example: ['en-US', 'ja', 'en-CA'] => ['en-US', 'en', 'ja', 'en-CA'].
// 'en' won't appear twice as this function eliminates duplicates.
@@ -471,6 +451,24 @@ void TranslatePrefs::CreateBlockedLanguages(
result.begin(), result.end());
}
+// static
+std::string TranslatePrefs::ConvertLangCodeForTranslation(
+ const std::string &lang) {
+ std::vector<std::string> tokens;
+ base::SplitString(lang, '-', &tokens);
+ if (tokens.size() < 1)
+ return lang;
+
+ std::string main_part = tokens[0];
+
+ // Translate doesn't support General Chinese and the sub code is necessary.
+ if (main_part == "zh")
+ return lang;
+
+ translate::ToTranslateLanguageSynonym(&main_part);
+ return main_part;
+}
+
bool TranslatePrefs::IsValueInList(const ListValue* list,
const std::string& in_value) const {
for (size_t i = 0; i < list->GetSize(); ++i) {
« no previous file with comments | « chrome/browser/translate/translate_prefs.h ('k') | components/translate/common/translate_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698