From 892d1a2d45f3a29ef32e755161ac5064ea6a0aeb Mon Sep 17 00:00:00 2001 From: floatinghotpot Date: Fri, 4 Dec 2015 10:39:51 +0800 Subject: i18n-ize meteor email templates --- config/accounts.js | 7 +++++++ i18n/en.i18n.json | 6 ++++++ models/users.js | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/config/accounts.js b/config/accounts.js index b1a4a177..3a6a116e 100644 --- a/config/accounts.js +++ b/config/accounts.js @@ -51,4 +51,11 @@ if (Meteor.isServer) { if (process.env.MAIL_FROM) { Accounts.emailTemplates.from = process.env.MAIL_FROM; } + + ['resetPassword-subject', 'resetPassword-text', 'verifyEmail-subject', 'verifyEmail-text', 'enrollAccount-subject', 'enrollAccount-text'].forEach((str) => { + const words = str.split('-'); + Accounts.emailTemplates[words[0]][words[1]] = (user, url) => { + return TAPi18n.__(`email-${str}`, { user: user.getName(), url }, user.getLanguage()); + }; + }); } diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 4a6edfe9..3f9e4e8b 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -124,6 +124,12 @@ "editLabelPopup-title": "Change Label", "editProfilePopup-title": "Edit Profile", "email": "Email", + "email-enrollAccount-subject": "An account created for you on __url__", + "email-enrollAccount-text": "Hello __user__,\n\nTo start using the service, simply click the link below.\n\n__url__\n\nThanks.\n", + "email-resetPassword-subject": "Reset your password on __url__", + "email-resetPassword-text": "Hello __user__,\n\nTo reset your password, simply click the link below.\n\n__url__\n\nThanks.\n", + "email-verifyEmail-subject": "Verify your email address on __url__", + "email-verifyEmail-text": "Hello __user__,\n\nTo verify your account email, simply click the link below.\n\n__url__\n\nThanks.\n", "error-board-notAMember": "You need to be a member of this board to do that", "error-json-malformed": "Your text is not valid JSON", "error-json-schema": "Your JSON data does not include the proper information in the correct format", diff --git a/models/users.js b/models/users.js index e85671bc..49c30127 100644 --- a/models/users.js +++ b/models/users.js @@ -68,6 +68,16 @@ Users.helpers({ return this.username[0].toUpperCase(); } }, + + getName() { + const profile = this.profile || {}; + return profile.fullname || this.username; + }, + + getLanguage() { + const profile = this.profile || {}; + return profile.language || 'en'; + }, }); Users.mutations({ -- cgit v1.2.3-1-g7c22