layouts.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Meteor.subscribe('boards');
  2. Meteor.subscribe('setting');
  3. Meteor.subscribe('user-admin');
  4. BlazeLayout.setRoot('body');
  5. const i18nTagToT9n = (i18nTag) => {
  6. // t9n/i18n tags are same now, see: https://github.com/softwarerero/meteor-accounts-t9n/pull/129
  7. // but we keep this conversion function here, to be aware that that they are different system.
  8. return i18nTag;
  9. };
  10. Template.userFormsLayout.onRendered(() => {
  11. const i18nTag = navigator.language;
  12. if (i18nTag) {
  13. T9n.setLanguage(i18nTagToT9n(i18nTag));
  14. }
  15. EscapeActions.executeAll();
  16. });
  17. Template.userFormsLayout.helpers({
  18. languages() {
  19. return _.map(TAPi18n.getLanguages(), (lang, tag) => {
  20. const name = lang.name;
  21. return { tag, name };
  22. });
  23. },
  24. isCurrentLanguage() {
  25. const t9nTag = i18nTagToT9n(this.tag);
  26. const curLang = T9n.getLanguage() || 'en';
  27. return t9nTag === curLang;
  28. },
  29. });
  30. Template.userFormsLayout.events({
  31. 'change .js-userform-set-language'(evt) {
  32. const i18nTag = $(evt.currentTarget).val();
  33. T9n.setLanguage(i18nTagToT9n(i18nTag));
  34. evt.preventDefault();
  35. },
  36. });
  37. Template.defaultLayout.events({
  38. 'click .js-close-modal': () => {
  39. Modal.close();
  40. },
  41. });