Merge pull request #563 from sharelatex/pr-support-html-encoded-i18n

Support HTML encoded i18n
This commit is contained in:
James Allen 2017-08-03 10:36:35 +02:00 committed by GitHub
commit 86a38df6e0
4 changed files with 11 additions and 3 deletions

View file

@ -11,6 +11,7 @@ async = require("async")
Modules = require "./Modules"
Url = require "url"
PackageVersions = require "./PackageVersions"
htmlEncoder = new require("node-html-encoder").Encoder("numerical")
fingerprints = {}
Path = require 'path'
@ -151,9 +152,10 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
next()
webRouter.use (req, res, next)->
res.locals.translate = (key, vars = {}) ->
res.locals.translate = (key, vars = {}, htmlEncode = false) ->
vars.appName = Settings.appName
req.i18n.translate(key, vars)
str = req.i18n.translate(key, vars)
if htmlEncode then htmlEncoder.htmlEncode(str) else str
# Don't include the query string parameters, otherwise Google
# treats ?nocdn=true as the canonical version
res.locals.currentUrl = Url.parse(req.originalUrl).pathname

View file

@ -82,7 +82,7 @@ div.full-size(
i.fa.fa-long-arrow-right
br
a.btn.btn-default.btn-xs(
tooltip-html="'"+translate('go_to_pdf_location_in_code')+"'"
tooltip-html="'"+translate('go_to_pdf_location_in_code', {}, true)+"'"
tooltip-placement="right"
tooltip-append-to-body="true"
ng-click="syncToCode()"

View file

@ -2728,6 +2728,11 @@
"from": "node-forge@0.2.24",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.2.24.tgz"
},
"node-html-encoder": {
"version": "0.0.2",
"from": "node-html-encoder@0.0.2",
"resolved": "https://registry.npmjs.org/node-html-encoder/-/node-html-encoder-0.0.2.tgz"
},
"node-pre-gyp": {
"version": "0.6.30",
"from": "node-pre-gyp@0.6.30",

View file

@ -41,6 +41,7 @@
"mongojs": "2.4.0",
"mongoose": "4.11.4",
"multer": "^0.1.8",
"node-html-encoder": "0.0.2",
"nodemailer": "2.1.0",
"nodemailer-sendgrid-transport": "^0.2.0",
"nodemailer-ses-transport": "^1.3.0",