mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00
Add email translations
Convert emails from Pug template to Handlebars because i18next doesn't support Pug
This commit is contained in:
parent
b45fbf4337
commit
d6e4dac032
223 changed files with 9859 additions and 1426 deletions
36
server/core/controllers/api/client-config.ts
Normal file
36
server/core/controllers/api/client-config.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { is18nLocale } from '@peertube/peertube-core-utils'
|
||||
import { HttpStatusCode } from '@peertube/peertube-models'
|
||||
import { setClientLanguageCookie } from '@server/helpers/i18n.js'
|
||||
import express from 'express'
|
||||
import { apiRateLimiter } from '../../middlewares/index.js'
|
||||
|
||||
const clientConfigRouter = express.Router()
|
||||
|
||||
clientConfigRouter.use(apiRateLimiter)
|
||||
|
||||
clientConfigRouter.post(
|
||||
'/update-interface-language',
|
||||
updateLanguage
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
clientConfigRouter
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function updateLanguage (req: express.Request, res: express.Response) {
|
||||
const language = req.body.language
|
||||
|
||||
if (language !== null && !is18nLocale(language)) {
|
||||
return res.fail({
|
||||
message: req.t('{language} is not a valid language', { language })
|
||||
})
|
||||
}
|
||||
|
||||
setClientLanguageCookie(res, language)
|
||||
|
||||
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue