From 2b8f94b244008947098c71567d4dcb70cd1dee11 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Sat, 15 Aug 2020 10:27:37 -0500 Subject: [PATCH] fix(escaping): global inoffensive apostrophe --- website/common/script/i18n.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/website/common/script/i18n.js b/website/common/script/i18n.js index 782504cf87..e452591cb2 100644 --- a/website/common/script/i18n.js +++ b/website/common/script/i18n.js @@ -1,5 +1,6 @@ import isString from 'lodash/isString'; import clone from 'lodash/clone'; +import forEach from 'lodash/forEach'; import template from 'lodash/template'; const i18n = { @@ -36,9 +37,16 @@ function t (stringName) { const clonedVars = clone(vars) || {}; + forEach(clonedVars, (val, key) => { + if (typeof clonedVars[key] === 'string') { + clonedVars[key] = clonedVars[key].replace(/'/g, '’'); + } + }); + clonedVars.locale = locale; if (string) { + string = string.replace(/'/g, '’'); try { return template(string)(clonedVars); } catch (_error) {