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

Commit 342ea31

Browse files
committed
Merge pull request #1631 from OpenBazaar/fixLanguageEdgeCase
Fix lang edge case
2 parents d890b32 + 0929197 commit 342ea31

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

js/start.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ var Polyglot = require('node-polyglot'),
6868
launchOnboarding,
6969
setServerUrl,
7070
guidCreating,
71-
platformClass;
71+
platformClass,
72+
updatePolyglot;
7273

7374
if (process.platform === 'darwin') {
7475
platformClass = 'platform-mac';
@@ -98,12 +99,16 @@ window.polyglot = new Polyglot({locale: window.lang});
9899
}
99100
})(window.lang);
100101

101-
user.on('change:language', function(md, lang) {
102+
updatePolyglot = function(lang){
102103
window.lang = lang;
103104
extendPolyglot(lang);
104105
localStorage.setItem('lang', lang);
105106
//trigger translation function on index
106107
window.translateIndex();
108+
};
109+
110+
user.on('change:language', function(md, lang) {
111+
updatePolyglot(lang);
107112
});
108113

109114
// add in our app bar
@@ -385,8 +390,15 @@ var loadProfile = function(landingRoute, onboarded) {
385390
//get the user
386391
user.fetch({
387392
success: function (model) {
393+
var userLang = model.get('language');
388394
cCode = model.get('currency_code');
389395

396+
if(userLang != window.polyglot.currentLocale){
397+
//when switching nodes, the language saved in localStorage can be different than the language in the
398+
// user model, but the user model does not trigger a change because it hasn't changed
399+
updatePolyglot(userLang);
400+
}
401+
390402
//get user bitcoin price before loading pages
391403
setCurrentBitCoin(cCode, user, function() {
392404
newSocketView = new socketView();

0 commit comments

Comments
 (0)