diff options
Diffstat (limited to 'client/lib/i18n.js')
-rw-r--r-- | client/lib/i18n.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/client/lib/i18n.js b/client/lib/i18n.js new file mode 100644 index 00000000..7d7e3ebb --- /dev/null +++ b/client/lib/i18n.js @@ -0,0 +1,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); + } +}); |