diff options
author | David Renshaw <david@sandstorm.io> | 2016-11-14 21:26:01 -0500 |
---|---|---|
committer | David Renshaw <david@sandstorm.io> | 2016-11-15 15:03:12 -0500 |
commit | f56c55e75c657d6348c4231779d410f4cdea7a04 (patch) | |
tree | d4b783e6b4c2aed62282c9edd7f92599194aba05 /client | |
parent | 1c206d0d367cbb4b6aa2e350ce944397bd48b988 (diff) | |
download | wekan-f56c55e75c657d6348c4231779d410f4cdea7a04.tar.gz wekan-f56c55e75c657d6348c4231779d410f4cdea7a04.tar.bz2 wekan-f56c55e75c657d6348c4231779d410f4cdea7a04.zip |
Wait until Meteor.startup() to set the language.
Diffstat (limited to 'client')
-rw-r--r-- | client/lib/i18n.js | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/client/lib/i18n.js b/client/lib/i18n.js index b8b8609d..f2709d15 100644 --- a/client/lib/i18n.js +++ b/client/lib/i18n.js @@ -2,26 +2,19 @@ // the language reactively. If the user is not connected we use the language // information provided by the browser, and default to english. -Tracker.autorun(() => { - const currentUser = Meteor.user(); - let language; - if (currentUser) { - language = currentUser.profile && currentUser.profile.language; - } else { - language = navigator.language || navigator.userLanguage; - } - - if (language) { - TAPi18n.setLanguage(language); +Meteor.startup(() => { + Tracker.autorun(() => { + const currentUser = Meteor.user(); + let language; + if (currentUser) { + language = currentUser.profile && currentUser.profile.language; + } else { + language = navigator.language || navigator.userLanguage; + } - // For languages such as Finnish (Suomi) that are not supported by meteor-accounts-t9n, - // the following may throw an exception. On the initial run of this `autorun()` callback, - // such an exception could cause the entire app to fail to load. Therefore, we catch - // the exception and log it as an error. - try { + if (language) { + TAPi18n.setLanguage(language); T9n.setLanguage(language); - } catch (e) { - console.error(e); } - } + }); }); |