diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-12-07 19:02:31 -0500 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-12-07 19:02:31 -0500 |
commit | 0623c8ea52926955981780a5c151c3607d582caa (patch) | |
tree | b5dadaca841d795dd5cefea2952be30d1fcefff7 /client/components/main/layouts.js | |
parent | d4581afd9b520dd034ea75f6e1ed0ab06bd67b5f (diff) | |
parent | ec130d448056d8adab77113646d8f8724931d128 (diff) | |
download | wekan-0623c8ea52926955981780a5c151c3607d582caa.tar.gz wekan-0623c8ea52926955981780a5c151c3607d582caa.tar.bz2 wekan-0623c8ea52926955981780a5c151c3607d582caa.zip |
Merge pull request #411 from floatinghotpot/patch-4
add: set user preferred lang and allow select lang for user form
Diffstat (limited to 'client/components/main/layouts.js')
-rw-r--r-- | client/components/main/layouts.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js index ab62e76a..3df17f41 100644 --- a/client/components/main/layouts.js +++ b/client/components/main/layouts.js @@ -2,10 +2,43 @@ Meteor.subscribe('boards'); BlazeLayout.setRoot('body'); +const i18nTagToT9n = (i18nTag) => { + // t9n/i18n tags are same now, see: https://github.com/softwarerero/meteor-accounts-t9n/pull/129 + // but we keep this conversion function here, to be aware that that they are different system. + return i18nTag; +}; + Template.userFormsLayout.onRendered(() => { + const i18nTag = navigator.language; + if (i18nTag) { + T9n.setLanguage(i18nTagToT9n(i18nTag)); + } EscapeActions.executeAll(); }); +Template.userFormsLayout.helpers({ + languages() { + return _.map(TAPi18n.getLanguages(), (lang, tag) => { + const name = lang.name; + return { tag, name }; + }); + }, + + isCurrentLanguage() { + const t9nTag = i18nTagToT9n(this.tag); + const curLang = T9n.getLanguage() || 'en'; + return t9nTag === curLang; + }, +}); + +Template.userFormsLayout.events({ + 'change .js-userform-set-language'(evt) { + const i18nTag = $(evt.currentTarget).val(); + T9n.setLanguage(i18nTagToT9n(i18nTag)); + evt.preventDefault(); + }, +}); + Template.defaultLayout.events({ 'click .js-close-modal': () => { Modal.close(); |