blob: 9d695bc893dd2ab428960f8d91252449c1ba340e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
'use strict';
function localize() {
var localized = 0;
var translate = function(messageID) {
localized++;
return chrome.i18n.getMessage(messageID);
};
$('[i18n]:not(.i18n-replaced)').each(function() {
var element = $(this);
element.html(translate(element.attr('i18n')));
element.addClass('i18n-replaced');
});
$('[data-i18n]:not(.i18n-replaced)').each(function() {
var element = $(this);
const translated = translate(element.data('i18n'));
element.html(translated);
element.addClass('i18n-replaced');
if (element.attr("title") !== "") {
element.attr("title", translated);
}
});
$('[i18n_title]:not(.i18n_title-replaced)').each(function() {
var element = $(this);
element.attr('title', translate(element.attr('i18n_title')));
element.addClass('i18n_title-replaced');
});
$('[data-i18n_title]:not(.i18n_title-replaced)').each(function() {
var element = $(this);
element.attr('title', translate(element.data('i18n_title')));
element.addClass('i18n_title-replaced');
});
$('[i18n_label]:not(.i18n_label-replaced)').each(function() {
var element = $(this);
element.attr('label', translate(element.attr('i18n_label')));
element.addClass('i18n_label-replaced');
});
$('[data-i18n_label]:not(.i18n_label-replaced)').each(function() {
var element = $(this);
element.attr('label', translate(element.data('i18n_label')));
element.addClass('i18n_label-replaced');
});
$('[i18n_value]:not(.i18n_value-replaced)').each(function() {
var element = $(this);
element.val(translate(element.attr('i18n_value')));
element.addClass('i18n_value-replaced');
});
$('[i18n_placeholder]:not(.i18n_placeholder-replaced)').each(function() {
var element = $(this);
element.attr('placeholder', translate(element.attr('i18n_placeholder')));
element.addClass('i18n_placeholder-replaced');
});
return localized;
}
|