. {t('sign_in.not_you')}
logout()}>
{t('sign_in.logout')}
diff --git a/plugins/coral-plugin-auth/client/components/styles.css b/plugins/coral-plugin-auth/client/components/styles.css
index d3cd47b87..c8fbf9a30 100644
--- a/plugins/coral-plugin-auth/client/components/styles.css
+++ b/plugins/coral-plugin-auth/client/components/styles.css
@@ -70,6 +70,10 @@ input.error{
letter-spacing: 0.1px;
}
+.userBoxLoggedIn {
+ font-weight: bold;
+}
+
.userBox a {
color: black;
font-weight: bold;
diff --git a/plugins/coral-plugin-auth/client/translations.yml b/plugins/coral-plugin-auth/client/translations.yml
index 488f505d6..bc7f06759 100644
--- a/plugins/coral-plugin-auth/client/translations.yml
+++ b/plugins/coral-plugin-auth/client/translations.yml
@@ -5,10 +5,10 @@ en:
verify_email: "Thank you for creating an account! We sent an email to the address you provided to verify your account."
verify_email2: "You must verify your account before engaging with the community."
not_you: "Not you?"
- logged_in_as: "Logged in as"
+ logged_in_as: "Signed in as"
facebook_sign_in: "Sign in with Facebook"
facebook_sign_up: "Sign up with Facebook"
- logout: "Logout"
+ logout: "Sign out"
sign_in: "Sign in"
sign_in_to_join: "Sign in to join the conversation"
or: "Or"
diff --git a/routes/api/users/index.js b/routes/api/users/index.js
index e7cc7d742..10d72fe3a 100644
--- a/routes/api/users/index.js
+++ b/routes/api/users/index.js
@@ -5,6 +5,7 @@ const CommentsService = require('../../../services/comments');
const mailer = require('../../../services/mailer');
const errors = require('../../../errors');
const authorization = require('../../../middleware/authorization');
+const i18n = require('../../../services/i18n');
const {
ROOT_URL
} = require('../../../config');
@@ -109,12 +110,12 @@ const SendEmailConfirmation = (app, userID, email, referer) => UsersService
.then((token) => {
return mailer.sendSimple({
template: 'email-confirm', // needed to know which template to render!
- locals: { // specifies the template locals.
+ locals: { // specifies the template locals.
token,
rootURL: ROOT_URL,
email
},
- subject: 'Email Confirmation',
+ subject: i18n.t('email.confirm.subject'),
to: email
});
});
diff --git a/services/email/email-confirm.html.ejs b/services/email/email-confirm.html.ejs
index dd2397edf..08a505521 100644
--- a/services/email/email-confirm.html.ejs
+++ b/services/email/email-confirm.html.ejs
@@ -1,3 +1,3 @@
-A email confirmation has been requested for the following account: <%= email %>.
-To confirm the account, please visit the following link: Confirm Email
-If you did not request this, you can safely ignore this email.
+<%= t('email.confirm.has_been_requested') %> <%= email %>.
+<%= t('email.confirm.to_confirm') %> Confirm Email
+<%= t('email.confirm.if_you_did_not') %>
diff --git a/services/email/email-confirm.txt.ejs b/services/email/email-confirm.txt.ejs
index 4c7d7d312..6d3cb219c 100644
--- a/services/email/email-confirm.txt.ejs
+++ b/services/email/email-confirm.txt.ejs
@@ -1,9 +1,9 @@
-A email confirmation has been requested for the following account:
+<%= t('email.confirm.has_been_requested') %>
<%= email %>
-To confirm the account, please visit the following link:
+<%= t('email.confirm.to_confirm') %>
<%= rootURL %>/confirm/endpoint#<%= token %>
-If you did not request this, you can safely ignore this email.
+<%= t('email.confirm.if_you_did_not') %>
diff --git a/services/email/password-reset.html.ejs b/services/email/password-reset.html.ejs
index e478ceeba..258f0d079 100644
--- a/services/email/password-reset.html.ejs
+++ b/services/email/password-reset.html.ejs
@@ -1,2 +1,2 @@
-We received a request to reset your password. If you did not request this change, you can ignore this email.
-If you did, please click here to reset password.
+<%= t('email.password_reset.we_received_a_request') %>
+<%= t('email.password_reset.if_you_did') %> <%= t('email.password_reset.please_click') %>.
diff --git a/services/email/password-reset.txt.ejs b/services/email/password-reset.txt.ejs
index 1e44a6629..a8387925d 100644
--- a/services/email/password-reset.txt.ejs
+++ b/services/email/password-reset.txt.ejs
@@ -1,5 +1,3 @@
-We received a request to reset your password, click here to reset your password:
+<%= t('email.password_reset.we_received_a_request') %>. <%= t('email.password_reset.if_you_did') %> <%= t('email.password_reset.please_click') %>:
<%= rootURL %>/admin/password-reset#<%= token %>
-
-If you did not request this change, you can ignore this email.
diff --git a/services/i18n.js b/services/i18n.js
new file mode 100644
index 000000000..eff827cac
--- /dev/null
+++ b/services/i18n.js
@@ -0,0 +1,53 @@
+const has = require('lodash/has');
+const get = require('lodash/get');
+
+const yaml = require('yamljs');
+const es = yaml.load('./locales/es.yml');
+const en = yaml.load('./locales/en.yml');
+
+const accepts = require('accepts');
+
+// default language
+let defaultLanguage = 'en';
+let language = defaultLanguage;
+const languages = ['en', 'es'];
+
+const translations = Object.assign(en, es);
+
+/**
+ * Exposes a service object to allow translations.
+ * @type {Object}
+ */
+const i18n = {
+
+ /**
+ * Create the new Task kue.
+ */
+ init(req) {
+ const lang = accepts(req).language(languages);
+ language = lang ? lang : defaultLanguage;
+ },
+
+ /**
+ * Translates a key.
+ */
+ t(key, ...replacements) {
+
+ if (has(translations[language], key)) {
+
+ let translation = get(translations[language], key);
+
+ // replace any {n} with the arguments passed to this method
+ replacements.forEach((str, i) => {
+ translation = translation.replace(new RegExp(`\\{${i}\\}`, 'g'), str);
+ });
+
+ return translation;
+ } else {
+ console.warn(`${key} language key not set`);
+ return key;
+ }
+ },
+};
+
+module.exports = i18n;
diff --git a/services/mailer.js b/services/mailer.js
index f3d9235ba..27672a35c 100644
--- a/services/mailer.js
+++ b/services/mailer.js
@@ -5,6 +5,8 @@ const path = require('path');
const fs = require('fs');
const _ = require('lodash');
+const i18n = require('./i18n');
+
const {
SMTP_HOST,
SMTP_USERNAME,
@@ -18,7 +20,7 @@ const templates = {
data: {}
};
-// load the temlates per request during development
+// load the templates per request during development
templates.render = (name, format = 'txt', context) => new Promise((resolve, reject) => {
// If we are in production mode, check the view cache.
@@ -50,7 +52,7 @@ templates.render = (name, format = 'txt', context) => new Promise((resolve, reje
return resolve(view(context));
});
-});
+}); // ends templates.render
const options = {
host: SMTP_HOST,
@@ -78,6 +80,7 @@ const mailer = module.exports = {
}),
sendSimple({template, locals, to, subject}) {
+
if (!to) {
return Promise.reject('sendSimple requires a comma-separated list of "to" addresses');
}
@@ -89,6 +92,8 @@ const mailer = module.exports = {
// Prefix the subject with `[Talk]`.
subject = `[Talk] ${subject}`;
+ locals['t'] = i18n.t;
+
return Promise.all([
// Render the HTML version of the email.
diff --git a/yarn.lock b/yarn.lock
index 40f9c6d3d..9855d91e8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8541,6 +8541,13 @@ yaml-loader@^0.4.0:
dependencies:
js-yaml "^3.5.2"
+yamljs@^0.2.10:
+ version "0.2.10"
+ resolved "https://registry.yarnpkg.com/yamljs/-/yamljs-0.2.10.tgz#481cc7c25ca73af59f591f0c96e3ce56c757a40f"
+ dependencies:
+ argparse "^1.0.7"
+ glob "^7.0.5"
+
yargs-parser@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4"