Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 16x 16x 16x 16x 64x 16x | import { Express } from 'express'
import Crowi from 'server/crowi'
import i18next from 'i18next'
import i18nFsBackend from 'i18next-node-fs-backend'
import i18nSprintf from 'i18next-sprintf-postprocessor'
import i18nMiddleware from 'i18next-express-middleware'
import i18nUserSettingDetector from '../util/i18nUserSettingDetector'
export default (crowi: Crowi, app: Express) => {
const User = crowi.model('User')
const lngDetector = new i18nMiddleware.LanguageDetector()
lngDetector.addDetector(i18nUserSettingDetector)
i18next
.use(lngDetector)
.use(i18nFsBackend)
.use(i18nSprintf)
.init({
// debug: (crowi.node_env === 'development'),
fallbackLng: [User.LANG_EN_US],
whitelist: Object.keys(User.getLanguageLabels()).map(k => User[k]),
backend: {
loadPath: crowi.localeDir + '{{lng}}/translation.yml',
},
detection: {
order: ['userSettingDetector', 'header', 'navigator'],
},
overloadTranslationOptionHandler: i18nSprintf.overloadTranslationOptionHandler,
})
return i18nMiddleware.handle(i18next)
}
|