OLD | NEW |
---|---|
1 // Copyright 2016 Google Inc. All rights reserved. | 1 // Copyright 2016 Google Inc. 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 // Load strings from messages.json into the HTML page. Each element that needs | 5 // Load strings from messages.json into the HTML page. Each element that needs |
6 // an internationalized string should have an 'i18n' property holding the | 6 // an internationalized string should have an 'i18n' property holding the |
7 // name of the message to be used. | 7 // name of the message to be used. If the element instead has an 'i18n-alt' |
8 function LoadInternationalizedStrings() { | 8 // property, that message will be used for the alt and title attributes of the |
9 // element (generally an image). | |
10 function loadInternationalizedStrings() { | |
9 var all = document.querySelectorAll('[i18n]'); | 11 var all = document.querySelectorAll('[i18n]'); |
10 for (var i = 0; i < all.length; ++i) { | 12 for (var i = 0; i < all.length; ++i) { |
11 var i18n = all[i].getAttribute('i18n'); | 13 var i18n = all[i].getAttribute('i18n'); |
12 if (i18n) | 14 if (i18n) |
13 all[i].textContent = chrome.i18n.getMessage(i18n); | 15 all[i].textContent = chrome.i18n.getMessage(i18n); |
14 } | 16 } |
17 | |
18 all = document.querySelectorAll('[i18n-alt]'); | |
19 for (var i = 0; i < all.length; ++i) { | |
20 var i18n = all[i].getAttribute('i18n-alt'); | |
21 if (i18n) { | |
Devlin
2016/11/01 15:12:14
When is this falsey? (Same for line 14)
Pam (message me for reviews)
2016/11/01 21:29:03
Leftover from a past version, when it iterated ove
| |
22 var message = chrome.i18n.getMessage(i18n); | |
23 all[i].alt = message; | |
24 all[i].title = message; | |
25 } | |
26 } | |
15 } | 27 } |
16 | 28 |
17 // Open a pre-filled email to send feedback to the extension developers. The | 29 // Open a pre-filled email to send feedback to the extension developers. The |
18 // initial content of the email depends on whether the URL of the current page | 30 // initial content of the email depends on whether the URL of the current page |
19 // is provided. | 31 // is provided. |
20 function reportPage(url) { | 32 function sendFeedback(url) { |
21 var subject = chrome.i18n.getMessage('reportSubject'); | 33 var subject = chrome.i18n.getMessage('reportSubject'); |
22 var body = ''; | 34 var body = ''; |
23 if (url) | 35 if (url) |
24 body = chrome.i18n.getMessage('reportBodyWithURL', url); | 36 body = chrome.i18n.getMessage('reportBodyWithURL', url); |
25 else | 37 else |
26 body = chrome.i18n.getMessage('reportBody'); | 38 body = chrome.i18n.getMessage('reportBody'); |
27 var msg = 'mailto:gobackwithbackspace@google.com' + | 39 var msg = 'mailto:gobackwithbackspace@google.com' + |
28 '?subject=' + encodeURIComponent(subject) + | 40 '?subject=' + encodeURIComponent(subject) + |
29 '&body=' + encodeURIComponent(body); | 41 '&body=' + encodeURIComponent(body); |
30 chrome.tabs.create({ | 42 chrome.tabs.create({ |
31 url: msg, | 43 url: msg, |
32 active: true}); | 44 active: true}); |
33 } | 45 } |
OLD | NEW |