Skip to content

Commit 8990e44

Browse files
authored
Merge pull request #2705 from uProxy/lucyhe-i18nworeload
Update strings in UI without reloading (fixes translation on Android!)
2 parents b4ffc75 + abf042f commit 8990e44

35 files changed

+250
-216
lines changed

src/chrome/extension/polymer/app-missing.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
}
2121
</style>
2222
<div>
23-
<h1>{{ "APP_MISSING_TITLE" | $$ }}</h1>
24-
<div>{{ "APP_MISSING_MESSAGE" | $$ }}</div><br>
25-
<paper-button class='highlightedButton' raised on-tap='{{ downloadApp }}'>{{ "NEXT" | $$ }}</paper-button>
23+
<h1>{{ "APP_MISSING_TITLE" | $$(model.globalSettings.language) }}</h1>
24+
<div>{{ "APP_MISSING_MESSAGE" | $$(model.globalSettings.language) }}</div><br>
25+
<paper-button class='highlightedButton' raised on-tap='{{ downloadApp }}'>{{ "NEXT" | $$(model.globalSettings.language) }}</paper-button>
2626
</div>
2727

2828
</template>

src/chrome/extension/polymer/app-missing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ function openDownloadAppPage() : void {
3535
Polymer({
3636
downloadApp: function() {
3737
openDownloadAppPage();
38+
},
39+
ready: function() {
40+
this.model = ui_context.model;
3841
}
3942
});

src/generic_ui/locales/en/messages.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@
185185
},
186186
"TOR_PORT_TRUE": {
187187
"description": "Info message displayed when there exists a reproxy listening at input port",
188-
"message": "Found server listening at port"
188+
"message": "Found server listening at port __number__"
189189
},
190190
"TOR_PORT_FALSE": {
191191
"description": "Info message displayed when we cannot find a reproxy listening at input port",
192-
"message": "Could not find server listening at port"
192+
"message": "Could not find server listening at port __number__"
193193
},
194194
"TOR_PORT_PENDING": {
195195
"description": "Info message displayed when searching for a reproxy listening at input port",
196-
"message": "Searching for server listening at port"
196+
"message": "Searching for server listening at port __number__"
197197
},
198198
"TOR_PORT_UNCHECKED": {
199199
"description": "Info message displayed when we haven't checked for a reproxy listening at input port",

src/generic_ui/locales/zh/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360
"description": "Label for button that will change the users Internet settings back to using the user's local connection (i.e. not their friend's Internet)."
361361
},
362362
"CONNECTED_WITH_NUMBER": {
363-
"message": "连接到 __数字 __网络",
363+
"message": "连接到 __number__ 网络",
364364
"description": "Text in settings informing the user of how many networks they're connected to."
365365
},
366366
"CLOUD_INSTALL_STATUS_INSTALLING_DOCKER": {

src/generic_ui/polymer/advanced-settings.html

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,17 @@
183183

184184
<!-- Listen for the 'open-advanced-settings' event, which is fired by the settings page. -->
185185
<core-signals on-core-signal-open-advanced-settings='{{ open }}'></core-signals>
186+
186187
<core-overlay id='advancedSettingsPanel'>
187188
<div id='container' vertical layout>
188189
<uproxy-app-bar on-go-back='{{ close }}'>
189-
{{ "ADVANCED_SETTINGS_SENTENCE_CASE" | $$ }}
190+
{{ "ADVANCED_SETTINGS_SENTENCE_CASE" | $$(model.globalSettings.language) }}
190191
</uproxy-app-bar>
191192
<div id='settingsContainer' flex>
192193
<div id='analyzeNAT'>
193194
<p class='inputLabel'>
194195
<uproxy-link on-tap='{{ viewLogs }}'>
195-
{{ "ANALYZE_NAT" | $$ }}
196+
{{ "ANALYZE_NAT" | $$(model.globalSettings.language) }}
196197
</uproxy-link>
197198
<uproxy-faq-link anchor='doesUproxyLogData'>
198199
<core-icon icon="help"></core-icon>
@@ -201,30 +202,30 @@
201202
</div>
202203
<div id='enableTor'>
203204
<p class='inputLabel'>
204-
{{ "TOR_ENABLE" | $$ }}
205+
{{ "TOR_ENABLE" | $$(model.globalSettings.language) }}
205206
<uproxy-faq-link anchor='howToEnableTorReproxy'>
206207
<core-icon icon="help"></core-icon>
207208
</uproxy-faq-link>
208209
<paper-toggle-button id='torEnableButton'></paper-toggle-button>
209210
</p>
210-
<paper-input-decorator id='torPortDecorator' label='{{ "TOR_PORT_PLACEHOLDER" | $$ }}' floatingLabel='{{ true }}' hidden?='{{ !$.torEnableButton.checked }}'>
211+
<paper-input-decorator id='torPortDecorator' label='{{ "TOR_PORT_PLACEHOLDER" | $$(model.globalSettings.language) }}' floatingLabel='{{ true }}' hidden?='{{ !$.torEnableButton.checked }}'>
211212
<input is='core-input' maxlength="5" value='{{ torPort }}' />
212213
</paper-input-decorator>
213214
<div id='torEnableToggledOn' hidden?='{{ !$.torEnableButton.checked }}'>
214215
<p class='advancedSettingsText' style='color:red;'>
215-
{{ "TOR_ENABLE_WARNING" | $$ }}
216+
{{ "TOR_ENABLE_WARNING" | $$(model.globalSettings.language) }}
216217
</p>
217218
<span class='advancedSettingsText' hidden?='{{ _reproxyCheckToString(reproxyCheck) !== "UNCHECKED" }}'>
218-
{{ 'TOR_PORT_UNCHECKED' | $$ }}
219+
{{ 'TOR_PORT_UNCHECKED' | $$(model.globalSettings.language) }}
219220
</span>
220221
<span class='advancedSettingsText' hidden?='{{ _reproxyCheckToString(reproxyCheck) !== "TRUE" }}'>
221-
{{ 'TOR_PORT_TRUE' | $$ }} {{ testedTorPort | $$ }}
222+
{{ 'TOR_PORT_TRUE' | $$(model.globalSettings.language, {number: testedTorPort}) }}
222223
</span>
223224
<span class='advancedSettingsText' style='color:red;' hidden?='{{ _reproxyCheckToString(reproxyCheck) !== "FALSE" }}'>
224-
{{ 'TOR_PORT_FALSE' | $$ }} {{ testedTorPort | $$ }}
225+
{{ 'TOR_PORT_FALSE' | $$(model.globalSettings.language, {number: testedTorPort}) }}
225226
</span>
226227
<span class='advancedSettingsText' hidden?='{{ _reproxyCheckToString(reproxyCheck) !== "PENDING" }}'>
227-
{{ 'TOR_PORT_PENDING' | $$ }} {{ testedTorPort | $$ }}
228+
{{ 'TOR_PORT_PENDING' | $$(model.globalSettings.language, {number: testedTorPort}) }}
228229
</span>
229230
<uproxy-link on-tap='{{ refreshReproxyCheck }}' role='button'>
230231
<core-icon icon='refresh'></core-icon>
@@ -234,49 +235,49 @@
234235
<div id='portControlBox'>
235236

236237
<p class='inputLabel'>
237-
{{ 'PORT_CONTROL_TITLE' | $$ }}
238+
{{ 'PORT_CONTROL_TITLE' | $$(model.globalSettings.language) }}
238239
<uproxy-faq-link anchor='whatIsPortControl'>
239240
<core-icon icon='help'></core-icon>
240241
</uproxy-faq-link>
241242
</p>
242243
<span class='label' hidden?='{{ !_supportsPortControl(portControlSupport) }}'>
243-
{{ 'PORT_CONTROL_SUPPORTED' | $$ }}
244+
{{ 'PORT_CONTROL_SUPPORTED' | $$(model.globalSettings.language) }}
244245
</span>
245246
<span class='label' hidden?='{{ !_doesNotSupportPortControl(portControlSupport) }}'>
246-
{{ 'PORT_CONTROL_NOT_SUPPORTED' | $$ }}
247+
{{ 'PORT_CONTROL_NOT_SUPPORTED' | $$(model.globalSettings.language) }}
247248
</span>
248249
<span class='label' hidden?='{{ !_portControlStatusPending(portControlSupport) }}'>
249-
{{ 'PORT_CONTROL_PENDING' | $$ }}
250+
{{ 'PORT_CONTROL_PENDING' | $$(model.globalSettings.language) }}
250251
</span>
251252
<uproxy-link on-tap='{{ refreshPortControl }}' role='button'>
252253
<core-icon icon='refresh'></core-icon>
253254
</uproxy-link>
254255
<p class='label info' hidden?='{{ !_doesNotSupportPortControl(portControlSupport) }}'>
255-
{{ 'PORT_CONTROL_NOT_SUPPORTED_INFO' | $$ }}
256+
{{ 'PORT_CONTROL_NOT_SUPPORTED_INFO' | $$(model.globalSettings.language) }}
256257
<uproxy-faq-link anchor='whatIsPortControl'>
257-
{{ 'MORE_INFO' | $$ }}
258+
{{ 'MORE_INFO' | $$(model.globalSettings.language) }}
258259
</uproxy-faq-link>
259260
</p>
260261
</div>
261262
<div id='formContainer' vertical layout>
262-
<p class='inputLabel'>{{ 'EDIT_ADVANCED_SETTINGS' | $$ }}</p>
263-
<paper-input-decorator id='advancedSettingsDecorator' label='{{ "EDIT_ADVANCED_SETTINGS_PLACEHOLDER" | $$ }}'>
263+
<p class='inputLabel'>{{ 'EDIT_ADVANCED_SETTINGS' | $$(model.globalSettings.language) }}</p>
264+
<paper-input-decorator id='advancedSettingsDecorator' label='{{ "EDIT_ADVANCED_SETTINGS_PLACEHOLDER" | $$(model.globalSettings.language) }}'>
264265
<textarea value='{{ settings }}' fit>
265266
</textarea>
266267
</paper-input-decorator>
267268
<p id='confirmSetAdvancedSettings' class='advancedSettingsText' hidden?='{{ !_statusStateIsSet(status) }}'>
268-
{{ "SETTINGS_SAVED" | $$ }}
269+
{{ "SETTINGS_SAVED" | $$(model.globalSettings.language) }}
269270
</p>
270271
<p id='failedSetAdvancedSettings' class='advancedSettingsText error' hidden?='{{ !_statusStateIsParseErorr(status) }}'>
271-
{{ "SETTINGS_BAD_FORMAT_ERROR" | $$ }}
272+
{{ "SETTINGS_BAD_FORMAT_ERROR" | $$(model.globalSettings.language) }}
272273
</p>
273274
<p id='failedKeyValueSetAdvancedSettings' class='advancedSettingsText error' hidden?='{{ !_statusStateIsKeyValueError(status) }}'>
274-
{{ "SETTINGS_JSON_ERROR" | $$ }}
275+
{{ "SETTINGS_JSON_ERROR" | $$(model.globalSettings.language) }}
275276
</p>
276277
</div> <!-- end of form container -->
277278
</div>
278279
<div id='setAdvancedSettings' on-tap='{{ setAdvancedSettings }}'>
279-
{{ "SET" | $$ }}
280+
{{ "SET" | $$(model.globalSettings.language) }}
280281
</div>
281282
</div>
282283
</core-overlay>

src/generic_ui/polymer/advanced-settings.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// user clicks set, we will overwrite the core change.
99

1010
import uproxy_core_api = require('../../interfaces/uproxy_core_api');
11+
import translator = require('../scripts/translator');
1112

1213
export enum StatusState {
1314
EMPTY,
@@ -64,6 +65,12 @@ Polymer({
6465
this.status = StatusState.KEY_VALUE_ERROR;
6566
return;
6667
}
68+
69+
if (ui_context.model.globalSettings.language != newSettings.language) {
70+
translator.i18n_setLng(newSettings.language);
71+
ui_context.ui.updateLanguage(newSettings.language);
72+
}
73+
6774
// User input values in "Enable Tor" div override JSON blob
6875
if (this.$.torEnableButton.checked) {
6976
this.torEnabled = true;
@@ -107,6 +114,9 @@ Polymer({
107114
this.reproxyCheck = check;
108115
});
109116
},
117+
ready: function() {
118+
this.model = ui_context.model;
119+
},
110120
computed: {
111121
'opened': '$.advancedSettingsPanel.opened'
112122
},

src/generic_ui/polymer/bubble.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<content></content>
9292

9393
<div id='actions'>
94-
<uproxy-button id='done' on-tap='{{ close }}'>{{ "DONE" | $$ }}</uproxy-button>
94+
<uproxy-button id='done' on-tap='{{ close }}'>{{ "DONE" | $$(model.globalSettings.language) }}</uproxy-button>
9595
</div>
9696
</div>
9797
</div>

src/generic_ui/polymer/bubble.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,8 @@ Polymer({
122122
} else {
123123
this.setAttribute('hidden', '');
124124
}
125+
},
126+
ready: function() {
127+
this.model = ui_context.model;
125128
}
126129
});

0 commit comments

Comments
 (0)