Email translations

This commit is contained in:
vjrj 2018-01-22 13:27:46 +01:00
parent 952431d296
commit 6c8fa91f64
30 changed files with 1844 additions and 107 deletions

View file

@ -5,6 +5,6 @@ import Notifications from '../Notifications';
Meteor.publish('mynotifications', function notifications() {
const notif = Notifications.find({ userId: this.userId, type: 'web', webNotified: null });
console.log(`Notifications for user ${this.userId}: ${notif.count()}`);
// console.log(`Notifications for user ${this.userId}: ${notif.count()}`);
return notif;
});

View file

@ -1,17 +1,20 @@
import i18n from 'i18next';
import sendEmail from '../../../modules/server/send-email';
import getOAuthProfile from '../../../modules/get-oauth-profile';
export default (options, user) => {
const OAuthProfile = getOAuthProfile(options, user);
const applicationName = '¡Tod@s contra el Fuego!';
const applicationName = i18n.t('AppName');
const firstName = OAuthProfile ? OAuthProfile.name.first : options.profile.name.first;
const emailAddress = OAuthProfile ? OAuthProfile.email : options.email;
const { lang } = user.lang;
return sendEmail({
to: emailAddress,
from: `${applicationName} <noreply@comunes.org>`,
subject: `[${applicationName}] Welcome, ${firstName}!`,
lang,
template: 'welcome',
templateVars: {
applicationName,

View file

@ -0,0 +1,26 @@
import fs from 'fs';
const as = f => `assets/app/${f}`;
export const getFallbackLang = (lang) => {
if (lang === 'ast' || lang === 'gl' || lang === 'eu' || lang === 'ca') {
return 'es';
}
return 'en';
};
export const getFileNameOfLang = (dir, fileName, ext, lang) => {
const base = `${dir}/${fileName}`;
const fallback = getFallbackLang(lang);
let file = `${base}-${lang}.${ext}`;
if (!fs.existsSync(as(file))) {
console.log(`Page '${fileName}' not found for '${lang}' lang`);
file = `${base}-${fallback}.${ext}`;
if (!fs.existsSync(as(file))) {
console.log(`Page '${fileName}' not found for '${fallback}' lang`);
file = `${base}.${ext}`;
}
}
return file;
};