summaryrefslogtreecommitdiffstats
path: root/client/lib/i18n.js
blob: 7d7e3ebb48961d4c9b5b2fb82cef714ed2984d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// We save the user language preference in the user profile, and use that to set
// the language reactively. If the user is not connected we use the language
// information provided by the browser, and default to english.

Tracker.autorun(function() {
  var language;
  var currentUser = Meteor.user();
  if (currentUser) {
    language = currentUser.profile && currentUser.profile.language;
  } else {
    language = navigator.language || navigator.userLanguage;
  }

  if (language) {

    TAPi18n.setLanguage(language);

    // XXX
    var shortLanguage = language.split('-')[0];
    T9n.setLanguage(shortLanguage);
  }
});