Merge pull request #18996 from overleaf/td-bs5-nav-react
Main navigation React component GitOrigin-RevId: c99a4b4a2f6fd02618689f829681118b2b64aa8d
This commit is contained in:
@@ -227,6 +227,26 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) {
|
||||
webRouter.use(function (req, res, next) {
|
||||
res.locals.translate = req.i18n.translate
|
||||
|
||||
const addTranslatedTextDeep = obj => {
|
||||
if (_.isObject(obj)) {
|
||||
if (_.has(obj, 'text')) {
|
||||
obj.translatedText = req.i18n.translate(obj.text)
|
||||
}
|
||||
_.forOwn(obj, value => {
|
||||
addTranslatedTextDeep(value)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// This function is used to add translations from the server for main
|
||||
// navigation items because it's tricky to get them in the front end
|
||||
// otherwise.
|
||||
res.locals.cloneAndTranslateText = obj => {
|
||||
const clone = _.cloneDeep(obj)
|
||||
addTranslatedTextDeep(clone)
|
||||
return clone
|
||||
}
|
||||
|
||||
// Don't include the query string parameters, otherwise Google
|
||||
// treats ?nocdn=true as the canonical version
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user