mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Wait until Meteor.startup() to set the language.
This commit is contained in:
parent
1c206d0d36
commit
f56c55e75c
1 changed files with 14 additions and 21 deletions
|
@ -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);
|
||||
|
||||
// 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 {
|
||||
T9n.setLanguage(language);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
Meteor.startup(() => {
|
||||
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);
|
||||
T9n.setLanguage(language);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue