Extracted strings and fixes on localization support
Language chooser in the UI
This commit is contained in:
parent
9f449c0a2f
commit
dc7789c17b
126 changed files with 2919 additions and 2028 deletions
|
@ -12,7 +12,8 @@ async function getAnonymousConfig(context, appType) {
|
|||
authMethod: passport.authMethod,
|
||||
isAuthMethodLocal: passport.isAuthMethodLocal,
|
||||
externalPasswordResetLink: config.ldap.passwordresetlink,
|
||||
language: config.language || 'en',
|
||||
defaultLanguage: config.defaultLanguage,
|
||||
enabledLanguages: config.enabledLanguages,
|
||||
isAuthenticated: !!context.user,
|
||||
trustedUrlBase: urls.getTrustedUrlBase(),
|
||||
trustedUrlBaseDir: urls.getTrustedUrlBaseDir(),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const config = require('config');
|
||||
|
||||
const knex = require('server/lib/knex')({
|
||||
const knex = require('knex')({
|
||||
client: 'mysql2',
|
||||
connection: config.mysql,
|
||||
migrations: {
|
||||
|
|
|
@ -17,8 +17,6 @@ const htmlToText = require('html-to-text');
|
|||
|
||||
const bluebird = require('bluebird');
|
||||
|
||||
const _ = require('./translate')._;
|
||||
|
||||
const transports = new Map();
|
||||
|
||||
async function getOrCreateMailer(sendConfigurationId) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const nodeify = require('server/lib/nodeify');
|
||||
const nodeify = require('nodeify');
|
||||
|
||||
module.exports.nodeifyPromise = nodeify;
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
const config = require('config');
|
||||
const log = require('./log');
|
||||
const _ = require('./translate')._;
|
||||
const util = require('util');
|
||||
|
||||
const passport = require('server/lib/passport');
|
||||
const passport = require('passport');
|
||||
const LocalStrategy = require('passport-local').Strategy;
|
||||
|
||||
const csrf = require('csurf');
|
||||
|
|
|
@ -26,7 +26,7 @@ async function sendSubscriptionConfirmed(lang, list, email, subscription) {
|
|||
unsubscribeUrl: '/subscription/' + list.cid + '/unsubscribe/' + subscription.cid
|
||||
};
|
||||
|
||||
await _sendMail(list, email, 'subscription_confirmed', lang, tMark('subscription.confirmed'), relativeUrls, subscription);
|
||||
await _sendMail(list, email, 'subscription_confirmed', lang, tMark('subscriptionconfirmed'), relativeUrls, subscription);
|
||||
}
|
||||
|
||||
async function sendAlreadySubscribed(lang, list, email, subscription) {
|
||||
|
@ -34,35 +34,35 @@ async function sendAlreadySubscribed(lang, list, email, subscription) {
|
|||
preferencesUrl: '/subscription/' + list.cid + '/manage/' + subscription.cid,
|
||||
unsubscribeUrl: '/subscription/' + list.cid + '/unsubscribe/' + subscription.cid
|
||||
};
|
||||
await _sendMail(list, email, 'already_subscribed', lang, tMark('subscription.alreadyRegistered'), relativeUrls, subscription);
|
||||
await _sendMail(list, email, 'already_subscribed', lang, tMark('listEmailAddressAlreadyRegistered'), relativeUrls, subscription);
|
||||
}
|
||||
|
||||
async function sendConfirmAddressChange(lang, list, email, cid, subscription) {
|
||||
const relativeUrls = {
|
||||
confirmUrl: '/subscription/confirm/change-address/' + cid
|
||||
};
|
||||
await _sendMail(list, email, 'confirm_address_change', lang, tMark('subscription.confirmEmailChange'), relativeUrls, subscription);
|
||||
await _sendMail(list, email, 'confirm_address_change', lang, tMark('listPleaseConfirmEmailChangeIn'), relativeUrls, subscription);
|
||||
}
|
||||
|
||||
async function sendConfirmSubscription(lang, list, email, cid, subscription) {
|
||||
const relativeUrls = {
|
||||
confirmUrl: '/subscription/confirm/subscribe/' + cid
|
||||
};
|
||||
await _sendMail(list, email, 'confirm_subscription', lang, tMark('subscription.confirmSubscription'), relativeUrls, subscription);
|
||||
await _sendMail(list, email, 'confirm_subscription', lang, tMark('pleaseConfirmSubscription'), relativeUrls, subscription);
|
||||
}
|
||||
|
||||
async function sendConfirmUnsubscription(lang, list, email, cid, subscription) {
|
||||
const relativeUrls = {
|
||||
confirmUrl: '/subscription/confirm/unsubscribe/' + cid
|
||||
};
|
||||
await _sendMail(list, email, 'confirm_unsubscription', lang, tMark('subscription.confirmUnsubscription'), relativeUrls, subscription);
|
||||
await _sendMail(list, email, 'confirm_unsubscription', lang, tMark('listPleaseConfirmUnsubscription'), relativeUrls, subscription);
|
||||
}
|
||||
|
||||
async function sendUnsubscriptionConfirmed(lang, list, email, subscription) {
|
||||
const relativeUrls = {
|
||||
subscribeUrl: '/subscription/' + list.cid + '?cid=' + subscription.cid
|
||||
};
|
||||
await _sendMail(list, email, 'unsubscription_confirmed', lang, tMark('subscription.unsubscriptionConfirmed'), relativeUrls, subscription);
|
||||
await _sendMail(list, email, 'unsubscription_confirmed', lang, tMark('listUnsubscriptionConfirmed'), relativeUrls, subscription);
|
||||
}
|
||||
|
||||
function getDisplayName(flds, subscription) {
|
||||
|
|
|
@ -101,11 +101,11 @@ function validateEmailGetMessage(result, address, language) {
|
|||
if (result !== 0) {
|
||||
switch (result) {
|
||||
case 5:
|
||||
return t('addressCheck.mxNotFound', {email: address});
|
||||
return t('invalidEmailAddressEmailMxRecordNotFound', {email: address});
|
||||
case 6:
|
||||
return t('addressCheck.domainNotFound', {email: address});
|
||||
return t('invalidEmailAddressEmailAddressDomainNot', {email: address});
|
||||
case 12:
|
||||
return t('addressCheck.domainRequired', {email: address});
|
||||
return t('invalidEmailAddressEmailAddressDomain', {email: address});
|
||||
default:
|
||||
return t('invalidEmailGeneric', {email: address});
|
||||
}
|
||||
|
|
|
@ -1,31 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
|
||||
const i18n = require("i18next");
|
||||
const Backend = require("i18next-node-fs-backend");
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {convertToFake, langCodes} = require('../../shared/langs');
|
||||
|
||||
const resourcesCommon = {};
|
||||
|
||||
function loadLanguage(shortCode) {
|
||||
resourcesCommon[shortCode] = {
|
||||
common: JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'locales', shortCode, 'common.json')))
|
||||
};
|
||||
}
|
||||
|
||||
loadLanguage('en');
|
||||
loadLanguage('es');
|
||||
resourcesCommon.fake = convertToFake(resourcesCommon.en);
|
||||
|
||||
const resources = {};
|
||||
for (const lng of config.enabledLanguages) {
|
||||
const shortCode = langCodes[lng].shortCode;
|
||||
resources[shortCode] = {
|
||||
common: resourcesCommon[shortCode]
|
||||
};
|
||||
}
|
||||
|
||||
i18n
|
||||
.use(Backend)
|
||||
// .use(Cache)
|
||||
.init({
|
||||
lng: config.language,
|
||||
|
||||
resources,
|
||||
wait: true, // globally set to wait for loaded translations in translate hoc
|
||||
|
||||
// have a common namespace used around the full app
|
||||
ns: ['common'],
|
||||
fallbackLng: config.defaultLanguage,
|
||||
defaultNS: 'common',
|
||||
|
||||
debug: true,
|
||||
|
||||
backend: {
|
||||
loadPath: path.join(__dirname, 'locales/{{lng}}/{{ns}}.json')
|
||||
}
|
||||
debug: false
|
||||
})
|
||||
|
||||
|
||||
|
||||
function tLog(key, args) {
|
||||
if (!args) {
|
||||
args = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue