Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit b25553a

Browse files
committed
laying the groundwork for localization
1 parent 2afc2f5 commit b25553a

File tree

5 files changed

+223
-45
lines changed

5 files changed

+223
-45
lines changed

_locales/en/messages.json

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
{
2+
"extName": {
3+
"message": "HTTP Switchboard",
4+
"description": "extension name."
5+
},
6+
"extShortDesc": {
7+
"message": "Point & click to forbid/allow any class of requests made by your browser. Use it to block scripts, iframes, ads, facebook, etc.",
8+
"description": "this will in chrome web store"
9+
},
10+
"ruleManagerPageName": {
11+
"message": "Rule manager",
12+
"description": "the name of Rule Manager page."
13+
},
14+
"statsPageName": {
15+
"message": "Statistics",
16+
"description": "the name of the Statistics page."
17+
},
18+
"settingsPageName": {
19+
"message": "Settings",
20+
"description": "the name of the Settings page."
21+
},
22+
23+
24+
"allPrettyName": {
25+
"message": "all",
26+
"description": "HAS TO FIT IN MATRIX HEADER!"
27+
},
28+
"cookiePrettyName": {
29+
"message": "cookie",
30+
"description": "HAS TO FIT IN MATRIX HEADER!"
31+
},
32+
"cookiePrettyNamePlural": {
33+
"message": "cookies",
34+
"description": "..."
35+
},
36+
"imagePrettyName": {
37+
"message": "image",
38+
"description": "HAS TO FIT IN MATRIX HEADER!"
39+
},
40+
"imagePrettyNamePlural": {
41+
"message": "images",
42+
"description": "..."
43+
},
44+
"objectPrettyName": {
45+
"message": "plugin",
46+
"description": "HAS TO FIT IN MATRIX HEADER!"
47+
},
48+
"objectPrettyNamePlural": {
49+
"message": "plugins",
50+
"description": "..."
51+
},
52+
"scriptPrettyName": {
53+
"message": "script",
54+
"description": "HAS TO FIT IN MATRIX HEADER!"
55+
},
56+
"scriptPrettyNamePlural": {
57+
"message": "scripts",
58+
"description": "..."
59+
},
60+
"xmlhttprequestPrettyName": {
61+
"message": "XHR",
62+
"description": "HAS TO FIT IN MATRIX HEADER!"
63+
},
64+
"xmlhttprequestPrettyNamePlural": {
65+
"message": "XHR",
66+
"description": "..."
67+
},
68+
"sub_framePrettyName": {
69+
"message": "frame",
70+
"description": "HAS TO FIT IN MATRIX HEADER!"
71+
},
72+
"sub_framePrettyNamePlural": {
73+
"message": "frames",
74+
"description": "..."
75+
},
76+
"otherPrettyName": {
77+
"message": "other",
78+
"description": "HAS TO FIT IN MATRIX HEADER!"
79+
},
80+
"otherPrettyNamePlural": {
81+
"message": "others",
82+
"description": "..."
83+
},
84+
85+
86+
"matrixRemoveScope" : {
87+
"message": "Remove all rules specific to {{what}}",
88+
"description": "hovering over the button to remove page scope"
89+
},
90+
"matrixCreateScope" : {
91+
"message": "Create rules specific to web pages which URL starts exactly with {{what}}",
92+
"description": "hovering over the button to add page scope"
93+
},
94+
"matrixRevert" : {
95+
"message": "Clear all temporary rules — those which are not padlocked",
96+
"description": "hovering over the button to clear temporary permissions"
97+
},
98+
99+
"matrixAllowAll" : {
100+
"message": "Click to <span class=\"gdt\">allow</span> all graylisted types and domains",
101+
"description": "used in matrix as user hover cells"
102+
},
103+
"matrixBlockAll" : {
104+
"message": "Click to <span class=\"rdt\">block</span> all graylisted types and domains",
105+
"description": "used in matrix as user hover cells"
106+
},
107+
"matrixAllowSomethingFromEverywhere" : {
108+
"message": "Click to <span class=\"gdt\">allow</span> <b>{{what}}</b> from <b>everywhere</b> except blacklisted hostnames",
109+
"description": "used in matrix as user hover cells"
110+
},
111+
"matrixAllowEverythingFromSomewhere" : {
112+
"message": "Click to <span class=\"gdt\">allow</span> <b>everything</b> from <b>{{where}}</b>",
113+
"description": "used in matrix as user hover cells"
114+
},
115+
"matrixAllowSomethingFromSomewhere" : {
116+
"message": "Click to <span class=\"gdt\">allow</span> <b>{{what}}</b> from <b>{{where}}</b>",
117+
"description": "used in matrix as user hover cells"
118+
},
119+
"matrixBlockSomethingFromEverywhere" : {
120+
"message": "Click to <span class=\"rdt\">block</span> <b>{{what}}</b> from <b>everywhere</b> except whitelisted hostnames",
121+
"description": "used in matrix as user hover cells"
122+
},
123+
"matrixBlockEverythingFromSomewhere" : {
124+
"message": "Click to <span class=\"rdt\">block</span> <b>everything</b> from <b>{{where}}</b>",
125+
"description": "used in matrix as user hover cells"
126+
},
127+
"matrixBlockSomethingFromSomewhere" : {
128+
"message": "Click to <span class=\"rdt\">block</span> <b>{{what}}</b> from <b>{{where}}</b>",
129+
"description": "used in matrix as user hover cells"
130+
},
131+
"matrixGraylistSomethingFromEverywhere" : {
132+
"message": "Click to graylist <b>{{what}}</b> from <b>everywhere</b>",
133+
"description": "used in matrix as user hover cells"
134+
},
135+
"matrixGraylistEverythingFromSomewhere" : {
136+
"message": "Click to graylist <b>everything</b> from <b>{{where}}</b>",
137+
"description": "used in matrix as user hover cells"
138+
},
139+
"matrixGraylistSomethingFromSomewhere" : {
140+
"message": "Click to graylist <b>{{what}}</b> from <b>{{where}}</b>",
141+
"description": "used in matrix as user hover cells"
142+
},
143+
"matrixPersistBlock" : {
144+
"message": "Permanently <span class=\"rdt\">blacklist</span> this cell",
145+
"description": "when user hover over red unlocked padlock"
146+
},
147+
"matrixPersistAllow" : {
148+
"message": "Permanently <span class=\"gdt\">whitelist</span> this cell",
149+
"description": "when user hover over green unlocked padlock"
150+
},
151+
"matrixUnpersistBlock" : {
152+
"message": "'Cancel the permanent <span class=\"rdt\">blacklist</span> status of this cell'",
153+
"description": "when user hover over red locked padlock"
154+
},
155+
"matrixUnpersistAllow" : {
156+
"message": "Cancel the permanent <span class=\"gdt\">whitelist</span> status of this cell",
157+
"description": "when user hover over green locked padlock"
158+
},
159+
160+
161+
"dummy": {
162+
"message": "This entry must be the last one",
163+
"description": "so we dont need to deal with comma for last entry"
164+
}
165+
}

info.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
padding: 0 0 20em 0;
99
font: 15px httpsb,sans-serif;
1010
}
11-
h3 + *, h1 + * {
11+
h2 + *, h1 + * {
1212
margin-left: 2em;
1313
}
1414
select {
@@ -29,7 +29,6 @@
2929
font-family: mono;
3030
background-color: white;
3131
overflow: scroll;
32-
resize: vertical;
3332
}
3433
#requests table {
3534
border-collapse: collapse;
@@ -74,7 +73,7 @@ <h1>HTTP Switchboard &mdash; Info</h1>
7473

7574

7675

77-
<h3>Whitelists/blacklists</h3>
76+
<h2>Whitelists/blacklists</h2>
7877
<div id="lists">
7978
<div style="white-space:nowrap;"> <!-- begin template 'stats' -->
8079
<div>
@@ -95,14 +94,14 @@ <h3>Whitelists/blacklists</h3>
9594
</div>
9695

9796

98-
<h3>Geeky stats</h3>
97+
<h2>Geeky stats</h2>
9998
<!-- start of geek stats --><div>For
10099
<select id="selectPageUrls">
101100
<option value="All">All</option>
102101
<option id="selectPageUrlTemplate" value="http://chromium.behind.the.scene">Chromium: Behind the scene</option>
103102
</select>
104103

105-
<h4>Overview</h4>
104+
<h3>Overview</h3>
106105
<div id="stats">
107106
<div style="white-space:nowrap;"> <!-- begin template 'stats' -->
108107

@@ -147,10 +146,10 @@ <h4>Overview</h4>
147146
</div>
148147

149148

150-
<h4>Detailed</h4>
149+
<h3>Detailed</h3>
151150
<div id="requests">
152-
<p><button id="refresh-requests">Refresh</button></p>
153-
<p>
151+
<p><button id="refresh-requests">Refresh</button></p>
152+
<p>
154153
Show: <input id="show-main_frame" type="checkbox" checked value="1">Pages&emsp;
155154
<input id="show-blocked" type="checkbox" checked value="1"><span style="color:#c00">Blocked</span>&emsp;
156155
<input id="show-allowed" type="checkbox" checked value="1"><span style="color:#070">Allowed</span>&emsp;
@@ -162,11 +161,11 @@ <h4>Detailed</h4>
162161
<input id="show-sub_frame" type="checkbox" checked value="1">Frames&emsp;
163162
<input id="show-other" type="checkbox" checked value="1">Others&emsp;
164163
</p>
165-
<div style="height: 400px">
166-
<table id="requestsTable">
167-
<tr id="requestRowTemplate"><td>...<td><td><a href="" style="display:none">&lt;a&gt;</a><td></tr>
168-
</table>
169-
</div>
164+
<div>
165+
<table id="requestsTable">
166+
<tr id="requestRowTemplate"><td>...<td><td><a href="" style="display:none">&lt;a&gt;</a><td></tr>
167+
</table>
168+
</div>
170169
</div>
171170

172171
</div> <!-- end of geek stats -->

js/popup.js

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ var HTTPSBPopup = {
114114

115115
matrixStats: MatrixStats.prototype.createMatrixStats(),
116116
matrixHeaderTypes: ['*'],
117-
matrixHeaderPrettyNames: { },
118117
matrixCellMenu: null,
119118
matrixCellHotspots: null,
120119
matrixRowTemplate: null,
@@ -126,6 +125,17 @@ var HTTPSBPopup = {
126125

127126
mouseenterHandlers: {},
128127

128+
matrixHeaderPrettyNames: {
129+
'all': '',
130+
'cookie': '',
131+
'image': '',
132+
'object': '',
133+
'script': '',
134+
'xmlhttprequest': '',
135+
'sub_frame': '',
136+
'other': ''
137+
},
138+
129139
// Just so the background page will be notified when popup menu is closed
130140
port: chrome.runtime.connect(),
131141

@@ -846,13 +856,15 @@ function initMenuEnvironment() {
846856
HTTPSBPopup.matrixRowTemplate = $('#templates .matRow');
847857

848858
var prettyNames = HTTPSBPopup.matrixHeaderPrettyNames;
849-
var cells = $('#matHead .matRow .matCell').toArray();
850-
var i = cells.length;
851-
var cell, type;
859+
var keys = Object.keys(prettyNames);
860+
var i = keys.length;
861+
var cell, key, text;
852862
while ( i-- ) {
853-
cell = $(cells[i]);
854-
type = cell.data('filterType');
855-
prettyNames[type] = cell.text();
863+
key = keys[i];
864+
cell = $('#matHead .matCell[data-filter-type="'+ key +'"]');
865+
text = chrome.i18n.getMessage(key + 'PrettyName');
866+
cell.text(text);
867+
prettyNames[key] = text;
856868
}
857869
}
858870

@@ -876,30 +888,27 @@ function toggleScopePage() {
876888
function getScopePageButtonTip() {
877889
var toolbar = $('body');
878890
if ( toolbar.hasClass('scope-is-page') ) {
879-
return 'Remove all rules specific to <b>' + HTTPSBPopup.scopeURL + '</b>';
891+
return chrome.i18n.getMessage('matrixRemoveScope').replace('{{what}}', '<b>' + HTTPSBPopup.scopeURL + '</b>');
880892
}
881-
return 'Create rules specific to web pages which URL starts exactly with ' +
882-
'<b>' + HTTPSBPopup.scopeURL + '</b>';
893+
return chrome.i18n.getMessage('matrixCreateScope').replace('{{what}}', '<b>' + HTTPSBPopup.scopeURL + '</b>');
883894
}
884895

885896
/******************************************************************************/
886897

887898
// Handle user mouse over filter buttons
888899

889-
// TODO: localize
890-
891900
var mouseOverPrompts = {
892-
'+**': 'Click to <span class="gdt">allow</span> all graylisted types and domains',
893-
'-**': 'Click to <span class="rdt">block</span> all graylisted types and domains',
894-
'+?*': 'Click to <span class="gdt">allow</span> <b>{{what}}</b> from <b>everywhere</b> except blacklisted domains',
895-
'+*?': 'Click to <span class="gdt">allow</span> <b>everything</b> from <b>{{where}}</b>',
896-
'+??': 'Click to <span class="gdt">allow</span> <b>{{what}}</b> from <b>{{where}}</b>',
897-
'-?*': 'Click to <span class="rdt">block</span> <b>{{what}}</b> from <b>everywhere</b> except whitelisted domains',
898-
'-*?': 'Click to <span class="rdt">block</span> <b>everything</b> from <b>{{where}}</b>',
899-
'-??': 'Click to <span class="rdt">block</span> <b>{{what}}</b> from <b>{{where}}</b>',
900-
'.?*': 'Click to graylist <b>{{what}}</b> from <b>everywhere</b>',
901-
'.*?': 'Click to graylist <b>everything</b> from <b>{{where}}</b>',
902-
'.??': 'Click to graylist <b>{{what}}</b> from <b>{{where}}</b>'
901+
'+**': chrome.i18n.getMessage('matrixAllowAll'),
902+
'-**': chrome.i18n.getMessage('matrixBlockAll'),
903+
'+?*': chrome.i18n.getMessage('matrixAllowSomethingFromEverywhere'),
904+
'+*?': chrome.i18n.getMessage('matrixAllowEverythingFromSomewhere'),
905+
'+??': chrome.i18n.getMessage('matrixAllowSomethingFromSomewhere'),
906+
'-?*': chrome.i18n.getMessage('matrixBlockSomethingFromEverywhere'),
907+
'-*?': chrome.i18n.getMessage('matrixBlockEverythingFromSomewhere'),
908+
'-??': chrome.i18n.getMessage('matrixBlockSomethingFromSomewhere'),
909+
'.?*': chrome.i18n.getMessage('matrixGraylistSomethingFromEverywhere'),
910+
'.*?': chrome.i18n.getMessage('matrixGraylistEverythingFromSomewhere'),
911+
'.??': chrome.i18n.getMessage('matrixGraylistSomethingFromSomewhere')
903912
};
904913

905914
function handleFilterMessage(hotspot, leaning) {
@@ -931,17 +940,17 @@ function handleBlacklistFilterMessage(hotspot) {
931940

932941
function handlePersistMessage(button) {
933942
if ( button.closest('.rdt').length ) {
934-
showMessage('Permanently <span class="rdt">blacklist</span> this cell');
943+
showMessage(chrome.i18n.getMessage('matrixPersistBlock'));
935944
} else if ( button.closest('.gdt').length ) {
936-
showMessage('Permanently <span class="gdt">whitelist</span> this cell');
945+
showMessage(chrome.i18n.getMessage('matrixPersistAllow'));
937946
}
938947
}
939948

940949
function handleUnpersistMessage(button) {
941950
if ( button.closest('.rdp').length ) {
942-
showMessage('Cancel the permanent <span class="rdt">blacklist</span> status of this cell');
951+
showMessage(chrome.i18n.getMessage('matrixUnpersistBlock'));
943952
} else if ( button.closest('.gdp').length ) {
944-
showMessage('Cancel the permanent <span class="gdt">whitelist</span> status of this cell');
953+
showMessage(chrome.i18n.getMessage('matrixUnpersistAllow'));
945954
}
946955
}
947956

@@ -1095,12 +1104,16 @@ function initAll() {
10951104
.on('mouseleave', blankMessage);
10961105

10971106
$('#buttonRevert')
1098-
.on('mouseenter', function() { showMessage('Clear all temporary rules &mdash; those which are not padlocked'); })
1107+
.on('mouseenter', function() { showMessage(chrome.i18n.getMessage('matrixRevert')); })
10991108
.on('mouseleave', blankMessage);
11001109

11011110
$('#buttonToggleScope').on('click', toggleScopePage);
11021111
$('#buttonRevert').on('click', revert);
11031112

1113+
$('#buttonRuleManager').text(chrome.i18n.getMessage('ruleManagerPageName'));
1114+
$('#buttonInfo').text(chrome.i18n.getMessage('statsPageName'));
1115+
$('#buttonSettings').text(chrome.i18n.getMessage('settingsPageName'));
1116+
11041117
$('#matList').on('click', '.groupSeparator.g3Meta', function() {
11051118
var separator = $(this);
11061119
separator.toggleClass('g3Collapsed');

manifest.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"manifest_version": 2,
3-
"name": "HTTP Switchboard",
3+
"name": "__MSG_extName__",
44
"version": "0.5.7",
5-
"description": "Point & click to forbid/allow any class of requests made by your browser. Use it to block scripts, iframes, ads, facebook, etc.",
5+
"description": "__MSG_extShortDesc__",
66
"icons": {
77
"128": "icon_128.png"
88
},
99
"browser_action": {
1010
"default_icon": {
1111
"19": "img/browsericons/icon19.png"
1212
},
13-
"default_title": "HTTP Switchboard",
13+
"default_title": "__MSG_extName__",
1414
"default_popup": "popup.html"
1515
},
1616
"author": "Raymond Hill",
@@ -19,6 +19,7 @@
1919
},
2020
"homepage_url": "https://github.com/gorhill/httpswitchboard/wiki",
2121
"minimum_chrome_version": "22.0",
22+
"default_locale": "en",
2223
"options_page": "settings.html",
2324
"permissions": [
2425
"contentSettings",

0 commit comments

Comments
 (0)