OLD | NEW |
---|---|
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 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 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 * page. | 122 * page. |
123 * @type {boolean} | 123 * @type {boolean} |
124 */ | 124 */ |
125 get error() { | 125 get error() { |
126 return error; | 126 return error; |
127 }, | 127 }, |
128 | 128 |
129 /** | 129 /** |
130 * The language the page translated was in. Is valid only after the page | 130 * The language the page translated was in. Is valid only after the page |
131 * has been successfully translated and the original language specified to | 131 * has been successfully translated and the original language specified to |
132 * the translate function was 'auto'. Is empty otherwise. | 132 * the translate function was 'auto'. Is empty otherwise. |
Evan Stade
2013/05/18 23:53:52
this comment needs updating.
Takashi Toyoshima
2013/05/20 06:56:08
Done.
| |
133 * @type {boolean} | 133 * @type {boolean} |
134 */ | 134 */ |
135 get sourceLang() { | 135 get sourceLang() { |
136 if (!libReady || !finished || error) | 136 if (!libReady || !finished || error) |
137 return ''; | 137 return ''; |
138 if (!lib.getDetectedLanguage) | |
139 return 'und'; | |
Evan Stade
2013/05/18 23:53:52
why 'und' and not undefined or 'undefined' or what
Takashi Toyoshima
2013/05/20 06:56:08
'und' is a magic word defined as chrome::kUnknownL
| |
138 return lib.getDetectedLanguage(); | 140 return lib.getDetectedLanguage(); |
Evan Stade
2013/05/18 23:53:52
you can write this as lib.getDetectedLanguage() ||
Takashi Toyoshima
2013/05/20 06:56:08
It doesn't work.
Undefined one is not returned val
Evan Stade
2013/05/23 00:53:28
ah, I misread it
| |
139 }, | 141 }, |
140 | 142 |
141 /** | 143 /** |
142 * Time in msec from this script being injected to all server side scripts | 144 * Time in msec from this script being injected to all server side scripts |
143 * being loaded. | 145 * being loaded. |
144 * @type {number} | 146 * @type {number} |
145 */ | 147 */ |
146 get loadTime() { | 148 get loadTime() { |
147 if (loadedTime == 0) | 149 if (loadedTime == 0) |
148 return 0; | 150 return 0; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 } catch (err) { | 210 } catch (err) { |
209 error = true; | 211 error = true; |
210 return; | 212 return; |
211 } | 213 } |
212 // The TranslateService is not available immediately as it needs to start | 214 // The TranslateService is not available immediately as it needs to start |
213 // Flash. Let's wait until it is ready. | 215 // Flash. Let's wait until it is ready. |
214 checkLibReady(); | 216 checkLibReady(); |
215 } | 217 } |
216 }; | 218 }; |
217 })/* Calling code '(|key|);' will be appended by TranslateHelper in C++ here. */ | 219 })/* Calling code '(|key|);' will be appended by TranslateHelper in C++ here. */ |
OLD | NEW |