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

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

Issue 10010019: JS style nits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: couple more Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/sync_setup_overlay.js ('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 (c) 2010 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 injected in a page to translate it from one language to another. 6 // It is injected in a page to translate it from one language to another.
7 // It should be included in the page before the Translate Element script. 7 // It should be included in the page before the Translate Element script.
8 8
9 var cr = {}; 9 var cr = {};
10 10
11 cr.googleTranslate = (function() { 11 cr.googleTranslate = (function() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 }, 67 },
68 68
69 /** 69 /**
70 * The language the page translated was in. Is valid only after the page 70 * The language the page translated was in. Is valid only after the page
71 * has been successfully translated and the original language specified to 71 * has been successfully translated and the original language specified to
72 * the translate function was 'auto'. Is empty otherwise. 72 * the translate function was 'auto'. Is empty otherwise.
73 * @type {boolean} 73 * @type {boolean}
74 */ 74 */
75 get sourceLang() { 75 get sourceLang() {
76 if (!libReady || !finished || error) 76 if (!libReady || !finished || error)
77 return ""; 77 return '';
78 return lib.getDetectedLanguage(); 78 return lib.getDetectedLanguage();
79 }, 79 },
80 80
81 /** 81 /**
82 * Translate the page contents. Note that the translation is asynchronous. 82 * Translate the page contents. Note that the translation is asynchronous.
83 * You need to regularly check the state of |finished| and |error| to know 83 * You need to regularly check the state of |finished| and |error| to know
84 * if the translation finished or if there was an error. 84 * if the translation finished or if there was an error.
85 * @param {string} originalLang The language the page is in. 85 * @param {string} originalLang The language the page is in.
86 * @param {string} targetLang The language the page should be translated to. 86 * @param {string} targetLang The language the page should be translated to.
87 * @return {boolean} False if the translate library was not ready, in which 87 * @return {boolean} False if the translate library was not ready, in which
(...skipping 13 matching lines...) Expand all
101 * any performed translation. Does nothing if the page was not translated. 101 * any performed translation. Does nothing if the page was not translated.
102 */ 102 */
103 revert: function() { 103 revert: function() {
104 lib.restore(); 104 lib.restore();
105 }, 105 },
106 106
107 /** 107 /**
108 * Entry point called by the Translate Element once it has been injected in 108 * Entry point called by the Translate Element once it has been injected in
109 * the page. 109 * the page.
110 */ 110 */
111 onTranslateElementLoad : function() { 111 onTranslateElementLoad: function() {
112 try { 112 try {
113 lib = google.translate.TranslateService({}); 113 lib = google.translate.TranslateService({});
114 } catch(err) { 114 } catch (err) {
115 error = true; 115 error = true;
116 return; 116 return;
117 } 117 }
118 // The TranslateService is not available immediately as it needs to start 118 // The TranslateService is not available immediately as it needs to start
119 // Flash. Let's wait until it is ready. 119 // Flash. Let's wait until it is ready.
120 checkLibReady(); 120 checkLibReady();
121 } 121 }
122 }; 122 };
123 })(); 123 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/sync_setup_overlay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698