diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/client.ts | 22 |
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' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import * as validator from 'validator' | 4 | import * as validator from 'validator' |
5 | import { escapeHTML, readFileBufferPromise, root } from '../helpers/core-utils' | 5 | import { escapeHTML, readFileBufferPromise, root } from '../helpers/core-utils' |
6 | import { | 6 | import { 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' | ||
14 | import { asyncMiddleware } from '../middlewares' | 7 | import { asyncMiddleware } from '../middlewares' |
15 | import { VideoModel } from '../models/video/video' | 8 | import { VideoModel } from '../models/video/video' |
16 | import { VideoPrivacy } from '../../shared/models/videos' | 9 | import { VideoPrivacy } from '../../shared/models/videos' |
17 | import { I18N_LOCALES, is18nLocale, getDefaultLocale } from '../../shared/models' | 10 | import { buildFileLocale, getCompleteLocale, getDefaultLocale, is18nLocale } from '../../shared/models' |
11 | import { LOCALE_FILES } from '../../shared/models/i18n/i18n' | ||
18 | 12 | ||
19 | const clientsRouter = express.Router() | 13 | const 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 | ||
99 | function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | 95 | function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { |