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

Side by Side Diff: chrome/browser/resources/translate.js

Issue 25531002: Move language detection to a component (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Run translate unittests on iOS 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This code is used in conjunction with the Google Translate Element script. 5 // This code is used in conjunction with the Google Translate Element script.
6 // It is executed in an isolated world of a page to translate it from one 6 // It is executed in an isolated world of a page to translate it from one
7 // language to another. 7 // language to another.
8 // It should be included in the page before the Translate Element script. 8 // It should be included in the page before the Translate Element script.
9 9
10 var cr = cr || {}; 10 var cr = cr || {};
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 * has been successfully translated and the original language specified to 172 * has been successfully translated and the original language specified to
173 * the translate function was 'auto'. Is empty otherwise. 173 * the translate function was 'auto'. Is empty otherwise.
174 * Some versions of Element library don't provide |getDetectedLanguage| 174 * Some versions of Element library don't provide |getDetectedLanguage|
175 * function. In that case, this function returns 'und'. 175 * function. In that case, this function returns 'und'.
176 * @type {boolean} 176 * @type {boolean}
177 */ 177 */
178 get sourceLang() { 178 get sourceLang() {
179 if (!libReady || !finished || errorCode != ERROR['NONE']) 179 if (!libReady || !finished || errorCode != ERROR['NONE'])
180 return ''; 180 return '';
181 if (!lib.getDetectedLanguage) 181 if (!lib.getDetectedLanguage)
182 return 'und'; // defined as chrome::kUnknownLanguageCode in C++ world. 182 return 'und'; // Defined as translate::kUnknownLanguageCode in C++.
183 return lib.getDetectedLanguage(); 183 return lib.getDetectedLanguage();
184 }, 184 },
185 185
186 /** 186 /**
187 * Time in msec from this script being injected to all server side scripts 187 * Time in msec from this script being injected to all server side scripts
188 * being loaded. 188 * being loaded.
189 * @type {number} 189 * @type {number}
190 */ 190 */
191 get loadTime() { 191 get loadTime() {
192 if (loadedTime == 0) 192 if (loadedTime == 0)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (this.status != 200) { 305 if (this.status != 200) {
306 errorCode = ERROR['SCRIPT_LOAD_ERROR']; 306 errorCode = ERROR['SCRIPT_LOAD_ERROR'];
307 return; 307 return;
308 } 308 }
309 eval(this.responseText); 309 eval(this.responseText);
310 } 310 }
311 xhr.send(); 311 xhr.send();
312 } 312 }
313 }; 313 };
314 })(); 314 })();
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/translate/translate_accept_languages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698