feat(localization): add localization for static strings

This commit is contained in:
David Litvak
2017-11-01 15:37:15 +01:00
committed by Benedikt Rötsch
parent eaec09a594
commit 68a8052bdf
24 changed files with 333 additions and 99 deletions

View File

@@ -1,4 +1,5 @@
const url = require('url')
const { translate } = require('../i18n/i18n')
module.exports = (modifier) => {
return (request, response, next) => {
@@ -6,7 +7,10 @@ module.exports = (modifier) => {
const urlComponents = url.parse(request.url).pathname.split('/').filter(Boolean)
let breadcrumbs = []
breadcrumbs.push({ label: 'Home', url: baseUrl })
breadcrumbs.push({
label: translate('homeLabel', response.locals.currentLocale.code),
url: baseUrl
})
// Map components of the path to breadcrumbs with resolvable URLs
let mappedComponents = urlComponents.map((component, i, array) => {
const path = array.slice(0, i + 1).join('/')