]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/client-html.ts
Refactor plugin card
[github/Chocobozzz/PeerTube.git] / server / lib / client-html.ts
index b2948254ba44792b612edec6afb2b3c81697a92b..e7e439bfe4bee38fbc00eb38c77fbb329efbe5ec 100644 (file)
@@ -4,11 +4,12 @@ import { join } from 'path'
 import validator from 'validator'
 import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
 import { escapeHTML } from '@shared/core-utils/renderer'
+import { sha256 } from '@shared/extra-utils'
 import { HTMLServerConfig } from '@shared/models'
 import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n'
 import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
 import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
-import { isTestInstance, sha256 } from '../helpers/core-utils'
+import { isTestInstance } from '../helpers/core-utils'
 import { logger } from '../helpers/logger'
 import { mdToPlainText } from '../helpers/markdown'
 import { CONFIG } from '../initializers/config'
@@ -350,10 +351,6 @@ class ClientHtml {
     return join(__dirname, '../../../client/dist/standalone/videos/embed.html')
   }
 
-  private static addHtmlLang (htmlStringPage: string, paramLang: string) {
-    return htmlStringPage.replace('<html>', `<html lang="${paramLang}">`)
-  }
-
   private static addManifestContentHash (htmlStringPage: string) {
     return htmlStringPage.replace('[manifestContentHash]', FILES_CONTENT_HASH.MANIFEST)
   }
@@ -555,9 +552,13 @@ class ClientHtml {
   }
 }
 
-function sendHTML (html: string, res: express.Response) {
+function sendHTML (html: string, res: express.Response, localizedHTML: boolean = false) {
   res.set('Content-Type', 'text/html; charset=UTF-8')
 
+  if (localizedHTML) {
+    res.set('Vary', 'Accept-Language')
+  }
+
   return res.send(html)
 }
 
@@ -586,5 +587,5 @@ export {
 async function generateHTMLPage (req: express.Request, res: express.Response, paramLang?: string) {
   const html = await ClientHtml.getDefaultHTMLPage(req, res, paramLang)
 
-  return sendHTML(html, res)
+  return sendHTML(html, res, true)
 }