diff --git a/public/src/app.js b/public/src/app.js index dfcc06ac09..2f5d84cec2 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -640,18 +640,24 @@ app.cacheBuster = null; } else if (window.localStorage.getItem('cookieconsent') === '1') { return; } - - templates.parse('partials/cookie-consent', config.cookies, function (html) { - $(document.body).append(html); - - var warningEl = $('.cookie-consent'); - var dismissEl = warningEl.find('button'); - dismissEl.on('click', function () { - // Save consent cookie and remove warning element - var now = new Date(); - window.localStorage.setItem('cookieconsent', '1'); - warningEl.remove(); + require(['translator'], function (translator) { + config.cookies.message = translator.unescape(config.cookies.message); + config.cookies.dismiss = translator.unescape(config.cookies.dismiss); + config.cookies.link = translator.unescape(config.cookies.link) + + app.parseAndTranslate('partials/cookie-consent', config.cookies, function (html) { + $(document.body).append(html); + + var warningEl = $('.cookie-consent'); + var dismissEl = warningEl.find('button'); + dismissEl.on('click', function () { + // Save consent cookie and remove warning element + var now = new Date(); + window.localStorage.setItem('cookieconsent', '1'); + warningEl.remove(); + }); }); }); + }; }()); diff --git a/src/controllers/api.js b/src/controllers/api.js index 10a5c8ad02..bc75a38aba 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -12,6 +12,7 @@ var categories = require('../categories'); var privileges = require('../privileges'); var plugins = require('../plugins'); var widgets = require('../widgets'); +var translator = require('../../public/src/modules/translator'); var accountHelpers = require('../controllers/accounts/helpers'); var apiController = {}; @@ -66,9 +67,9 @@ apiController.getConfig = function (req, res, next) { config.cookies = { enabled: parseInt(meta.config.cookieConsentEnabled, 10) === 1, - message: meta.config.cookieConsentMessage || '[[global:cookies.message]]', - dismiss: meta.config.cookieConsentDismiss || '[[global:cookies.accept]]', - link: meta.config.cookieConsentLink || '[[global:cookies.learn_more]]' + message: translator.escape(meta.config.cookieConsentMessage || '[[global:cookies.message]]').replace(/\\/g, '\\\\'), + dismiss: translator.escape(meta.config.cookieConsentDismiss || '[[global:cookies.accept]]').replace(/\\/g, '\\\\'), + link: translator.escape(meta.config.cookieConsentLink || '[[global:cookies.learn_more]]').replace(/\\/g, '\\\\') }; async.waterfall([