layouts.js 1.1 KB

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