Extracted strings and fixes on localization support

Language chooser in the UI
This commit is contained in:
Tomas Bures 2018-11-18 21:31:22 +01:00
parent 9f449c0a2f
commit dc7789c17b
126 changed files with 2919 additions and 2028 deletions

View file

@ -62,7 +62,7 @@ router.postAsync('/subscribe/:listCid', passport.loggedIn, async (req, res) => {
};
const confirmCid = await confirmations.addConfirmation(list.id, 'subscribe', req.ip, data);
await mailHelpers.sendConfirmSubscription(config.language, list, input.EMAIL, confirmCid, subscription);
await mailHelpers.sendConfirmSubscription(req.language, list, input.EMAIL, confirmCid, subscription);
res.status(200);
res.json({

View file

@ -1,7 +1,6 @@
'use strict';
const passport = require('../lib/passport');
const _ = require('../lib/translate')._;
const clientHelpers = require('../lib/client-helpers');
const { getTrustedUrl } = require('../lib/urls');
const { AppType } = require('../../shared/app');

View file

@ -1,7 +1,6 @@
'use strict';
const passport = require('../../lib/passport');
const _ = require('../../lib/translate')._;
const users = require('../../models/users');
const contextHelpers = require('../../lib/context-helpers');

View file

@ -1,7 +1,6 @@
'use strict';
const passport = require('../../lib/passport');
const _ = require('../../lib/translate')._;
const namespaces = require('../../models/namespaces');
const router = require('../../lib/router-async').create();

View file

@ -1,7 +1,6 @@
'use strict';
const passport = require('../../lib/passport');
const _ = require('../../lib/translate')._;
const reportTemplates = require('../../models/report-templates');
const router = require('../../lib/router-async').create();

View file

@ -1,7 +1,6 @@
'use strict';
const passport = require('../../lib/passport');
const _ = require('../../lib/translate')._;
const reports = require('../../models/reports');
const reportProcessor = require('../../lib/report-processor');
const reportHelpers = require('../../lib/report-helpers');

View file

@ -1,7 +1,6 @@
'use strict';
const passport = require('../../lib/passport');
const _ = require('../../lib/translate')._;
const shares = require('../../models/shares');
const router = require('../../lib/router-async').create();

View file

@ -2,7 +2,6 @@
const config = require('config');
const passport = require('../../lib/passport');
const _ = require('../../lib/translate')._;
const users = require('../../models/users');
const shares = require('../../models/shares');

View file

@ -152,7 +152,7 @@ function getRouter(appType) {
});
// This is a fallback to versafix-1 if the block thumbnail is not defined by the template
router.use('/templates/:mosaicoTemplateId/edres', express.static(path.join(__dirname, '..', 'client', 'static', 'mosaico', 'templates', 'versafix-1', 'edres')));
router.use('/templates/:mosaicoTemplateId/edres', express.static(path.join(__dirname, '..', '..', 'client', 'static', 'mosaico', 'templates', 'versafix-1', 'edres')));
fileHelpers.installUploadHandler(router, '/upload/:type/:entityId', files.ReplacementBehavior.RENAME, null, 'file', resp => {
@ -185,10 +185,10 @@ function getRouter(appType) {
const mailtrainConfig = await clientHelpers.getAnonymousConfig(req.context, appType);
let languageStrings = null;
if (config.language && config.language !== 'en') {
const lang = config.language.split('_')[0];
const lang = req.language;
if (lang && lang !== 'en') {
try {
const file = path.join(__dirname, '..', 'client', 'static', 'mosaico', 'lang', 'mosaico-' + lang + '.json');
const file = path.join(__dirname, '..', '..', 'client', 'static', 'mosaico', 'lang', 'mosaico-' + lang + '.json');
languageStrings = await fs.readFile(file, 'utf8');
} catch (err) {
}
@ -232,7 +232,7 @@ function getRouter(appType) {
const mosaicoLegacyUrlPrefix = getTrustedUrl(`mosaico/uploads/`);
if (url.startsWith(mosaicoLegacyUrlPrefix)) {
filePath = path.join(__dirname, '..', 'client', 'static' , 'mosaico', 'uploads', url.substring(mosaicoLegacyUrlPrefix.length));
filePath = path.join(__dirname, '..', '..', 'client', 'static' , 'mosaico', 'uploads', url.substring(mosaicoLegacyUrlPrefix.length));
} else {
const file = await files.getFileByUrl(contextHelpers.getAdminContext(), url);
filePath = file.path;

View file

@ -141,7 +141,7 @@ router.getAsync('/confirm/change-address/:cid', async (req, res) => {
await mailHelpers.sendSubscriptionConfirmed(req.language, list, data.emailNew, subscription);
req.flash('info', tUI('subscription.emailChanged', req.language));
req.flash('info', tUI('emailAddressChanged', req.language));
res.redirect('/subscription/' + encodeURIComponent(list.cid) + '/manage/' + subscription.cid);
});
@ -244,7 +244,7 @@ router.postAsync('/:cid/subscribe', passport.parseForm, corsOrCsrfProtection, as
throw new Error('Email address not set');
}
req.flash('danger', tUI('subscription.addressNotSet', req.language));
req.flash('danger', tUI('emailAddressNotSet', req.language));
return await _renderSubscribe(req, res, list, subscriptionData);
}
@ -300,7 +300,7 @@ router.postAsync('/:cid/subscribe', passport.parseForm, corsOrCsrfProtection, as
if (req.xhr) {
return res.status(200).json({
msg: tUI('subscription.confirmSubscription', req.language)
msg: tUI('pleaseConfirmSubscription', req.language)
});
}
res.redirect('/subscription/' + encodeURIComponent(req.params.cid) + '/confirm-subscription-notice');
@ -457,7 +457,7 @@ router.postAsync('/:lcid/manage-address', passport.parseForm, passport.csrfProte
}
if (subscription.email === emailNew) {
req.flash('info', tUI('subscription.nothingChanged', req.language));
req.flash('info', tUI('nothingSeemsToBeChanged', req.language));
} else {
const emailErr = await tools.validateEmail(emailNew);
@ -489,7 +489,7 @@ router.postAsync('/:lcid/manage-address', passport.parseForm, passport.csrfProte
await mailHelpers.sendConfirmAddressChange(req.language, list, emailNew, confirmCid, subscription);
}
req.flash('info', tUI('subscription.furtherInstructionsSent', req.language));
req.flash('info', tUI('anEmailWithFurtherInstructionsHasBeen', req.language));
}
}