Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit b171cc7

Browse files
committed
showing dialog and restarting on lang change
1 parent 741dbd6 commit b171cc7

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

js/languages/en-US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@
743743
"newConfigTitle": "New Configuration",
744744
"new": "New"
745745
},
746+
"langChangeRestartTitle": "Restart needed for language change",
747+
"langChangeRestartMessage": "In order for your language change to fully take effect, you must restart the app.",
746748
"timezones": {
747749
"-12": "(GMT -12:00) Eniwetok, Kwajalein",
748750
"-11": "(GMT -11:00) Midway Island, Samoa",

js/start.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var Polyglot = require('node-polyglot'),
5252
ServerConnectModal = require('./views/serverConnectModal'),
5353
OnboardingModal = require('./views/onboardingModal'),
5454
PageConnectModal = require('./views/pageConnectModal'),
55+
Dialog = require('./views/dialog.js'),
5556
loadProfileNeeded = true,
5657
startUpConnectMaxRetries = 2,
5758
startUpConnectRetryDelay = 2 * 1000,
@@ -107,6 +108,11 @@ updatePolyglot = function(lang){
107108
};
108109

109110
user.on('change:language', function(md, lang) {
111+
// Re-starting the app on lang change. For now leaving in the code in various global views
112+
// that deals with lang change.
113+
// TODO: Once it looks like the restart on lang change approach is fine, go into the different
114+
// views and cleanup any code dealing with lang change.
115+
110116
updatePolyglot(lang);
111117
});
112118

@@ -444,7 +450,28 @@ var loadProfile = function(landingRoute, onboarded) {
444450
app.simpleMessageModal.remove = () => {
445451
throw new Error('This instance of the simpleMessageModal is globally shared ' +
446452
'and should not be removed. When you are done with it, please close it.');
447-
};
453+
};
454+
455+
// any lang changes after our app has loaded will need an app re-start to fully take effect
456+
user.on('change:language', function(md, lang) {
457+
var restartWarning;
458+
459+
restartWarning = new Dialog({
460+
title: window.polyglot.t('langChangeRestartTitle'),
461+
message: window.polyglot.t('langChangeRestartMessage'),
462+
buttons: [{
463+
text: 'Restart Later',
464+
fragment: 'restart-later'
465+
}, {
466+
text: 'Restart Now',
467+
fragment: 'restart-now'
468+
}]
469+
}).on('click-restart-later', () => {
470+
restartWarning.close();
471+
}).on('click-restart-now', () => {
472+
location.reload();
473+
}).render().open();
474+
});
448475

449476
app.router = new router({userModel: user, userProfile: userProfile, socketView: newSocketView});
450477

0 commit comments

Comments
 (0)