@@ -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
109110user . 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