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

Side by Side Diff: components/translate/common/translate_util.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/translate/translate_prefs.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/translate_util.h" 5 #include "components/translate/common/translate_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 *language = kLanguageCodeSimilitudes[i].translate_language; 70 *language = kLanguageCodeSimilitudes[i].translate_language;
71 return; 71 return;
72 } 72 }
73 } 73 }
74 74
75 std::string main_part, tail_part; 75 std::string main_part, tail_part;
76 SplitIntoMainAndTail(*language, &main_part, &tail_part); 76 SplitIntoMainAndTail(*language, &main_part, &tail_part);
77 if (main_part.empty()) 77 if (main_part.empty())
78 return; 78 return;
79 79
80 // Apply liner search here because number of items in the list is just four. 80 // Apply linear search here because number of items in the list is just four.
81 for (size_t i = 0; i < arraysize(kLanguageCodeSynonyms); ++i) { 81 for (size_t i = 0; i < arraysize(kLanguageCodeSynonyms); ++i) {
82 if (main_part == kLanguageCodeSynonyms[i].chrome_language) { 82 if (main_part == kLanguageCodeSynonyms[i].chrome_language) {
83 main_part = std::string(kLanguageCodeSynonyms[i].translate_language); 83 main_part = std::string(kLanguageCodeSynonyms[i].translate_language);
84 break; 84 break;
85 } 85 }
86 } 86 }
87 87
88 *language = main_part + tail_part; 88 *language = main_part + tail_part;
89 } 89 }
90 90
(...skipping 25 matching lines...) Expand all
116 std::string security_origin(kSecurityOrigin); 116 std::string security_origin(kSecurityOrigin);
117 CommandLine* command_line = CommandLine::ForCurrentProcess(); 117 CommandLine* command_line = CommandLine::ForCurrentProcess();
118 if (command_line->HasSwitch(switches::kTranslateSecurityOrigin)) { 118 if (command_line->HasSwitch(switches::kTranslateSecurityOrigin)) {
119 security_origin = 119 security_origin =
120 command_line->GetSwitchValueASCII(switches::kTranslateSecurityOrigin); 120 command_line->GetSwitchValueASCII(switches::kTranslateSecurityOrigin);
121 } 121 }
122 return GURL(security_origin); 122 return GURL(security_origin);
123 } 123 }
124 124
125 } // namespace translate 125 } // namespace translate
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_prefs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698