aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r--server/controllers/client.ts22
1 files changed, 9 insertions, 13 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index ec78a4bbc..385757fa6 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -3,18 +3,12 @@ import * as express from 'express'
3import { join } from 'path' 3import { join } from 'path'
4import * as validator from 'validator' 4import * as validator from 'validator'
5import { escapeHTML, readFileBufferPromise, root } from '../helpers/core-utils' 5import { escapeHTML, readFileBufferPromise, root } from '../helpers/core-utils'
6import { 6import { ACCEPT_HEADERS, CONFIG, EMBED_SIZE, OPENGRAPH_AND_OEMBED_COMMENT, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers'
7 ACCEPT_HEADERS,
8 CONFIG,
9 EMBED_SIZE,
10 OPENGRAPH_AND_OEMBED_COMMENT,
11 STATIC_MAX_AGE,
12 STATIC_PATHS
13} from '../initializers'
14import { asyncMiddleware } from '../middlewares' 7import { asyncMiddleware } from '../middlewares'
15import { VideoModel } from '../models/video/video' 8import { VideoModel } from '../models/video/video'
16import { VideoPrivacy } from '../../shared/models/videos' 9import { VideoPrivacy } from '../../shared/models/videos'
17import { I18N_LOCALES, is18nLocale, getDefaultLocale } from '../../shared/models' 10import { buildFileLocale, getCompleteLocale, getDefaultLocale, is18nLocale } from '../../shared/models'
11import { LOCALE_FILES } from '../../shared/models/i18n/i18n'
18 12
19const clientsRouter = express.Router() 13const clientsRouter = express.Router()
20 14
@@ -51,8 +45,10 @@ clientsRouter.use('/client/locales/:locale/:file.json', function (req, res) {
51 const locale = req.params.locale 45 const locale = req.params.locale
52 const file = req.params.file 46 const file = req.params.file
53 47
54 if (is18nLocale(locale) && [ 'player', 'server' ].indexOf(file) !== -1) { 48 if (is18nLocale(locale) && LOCALE_FILES.indexOf(file) !== -1) {
55 return res.sendFile(join(__dirname, `../../../client/dist/locale/${file}_${locale}.json`)) 49 const completeLocale = getCompleteLocale(locale)
50 const completeFileLocale = buildFileLocale(completeLocale)
51 return res.sendFile(join(__dirname, `../../../client/dist/locale/${file}_${completeFileLocale}.json`))
56 } 52 }
57 53
58 return res.sendStatus(404) 54 return res.sendStatus(404)
@@ -88,12 +84,12 @@ function getIndexPath (req: express.Request, paramLang?: string) {
88 if (paramLang && is18nLocale(paramLang)) { 84 if (paramLang && is18nLocale(paramLang)) {
89 lang = paramLang 85 lang = paramLang
90 } else { 86 } else {
91 // lang = req.acceptsLanguages(Object.keys(I18N_LOCALES)) || getDefaultLocale() 87 // lang = req.acceptsLanguages(POSSIBLE_LOCALES) || getDefaultLocale()
92 // Disable auto language for now 88 // Disable auto language for now
93 lang = getDefaultLocale() 89 lang = getDefaultLocale()
94 } 90 }
95 91
96 return join(__dirname, '../../../client/dist/' + lang + '/index.html') 92 return join(__dirname, '../../../client/dist/' + buildFileLocale(lang) + '/index.html')
97} 93}
98 94
99function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { 95function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {