1 import { writeJSON } from 'fs-extra'
2 import { values } from 'lodash'
3 import { join } from 'path'
4 import { registerTSPaths } from '../../server/helpers/register-ts-paths'
10 VIDEO_PLAYLIST_PRIVACIES,
14 } from '../../server/initializers/constants'
15 import { I18N_LOCALES } from '../../shared/core-utils/i18n'
19 const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
24 'Subtitles/CC': 'Subtitles/CC',
27 'Go to the video page': 'Go to the video page',
28 'Settings': 'Settings',
29 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
30 'Copy the video URL': 'Copy the video URL',
31 'Copy the video URL at the current time': 'Copy the video URL at the current time',
32 'Copy embed code': 'Copy embed code',
33 'Copy magnet URI': 'Copy magnet URI',
34 'Total downloaded: ': 'Total downloaded: ',
35 'Total uploaded: ': 'Total uploaded: ',
36 'From servers: ': 'From servers: ',
37 'From peers: ': 'From peers: ',
38 'Normal mode': 'Normal mode',
39 'Stats for nerds': 'Stats for nerds',
40 'Theater mode': 'Theater mode',
41 'Video UUID': 'Video UUID',
42 'Viewport / Frames': 'Viewport / Frames',
43 'Resolution': 'Resolution',
47 'Connection Speed': 'Connection Speed',
48 'Network Activity': 'Network Activity',
49 'Total Transfered': 'Total Transfered',
50 'Download Breakdown': 'Download Breakdown',
51 'Buffer Progress': 'Buffer Progress',
52 'Buffer State': 'Buffer State',
53 'Live Latency': 'Live Latency'
55 Object.assign(playerKeys, videojs)
58 const serverKeys: any = {}
59 values(VIDEO_CATEGORIES)
60 .concat(values(VIDEO_LICENCES))
61 .concat(values(VIDEO_PRIVACIES))
62 .concat(values(VIDEO_STATES))
63 .concat(values(VIDEO_IMPORT_STATES))
64 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
65 .concat(values(VIDEO_PLAYLIST_TYPES))
67 'This video does not exist.',
68 'We cannot fetch the video. Please try again later.',
70 'This video is not available because the remote instance is not responding.',
71 'This playlist does not exist',
72 'We cannot fetch the playlist. Please try again later.',
77 .forEach(v => { serverKeys[v] = v })
80 Object.assign(serverKeys, {
86 const languageKeys: any = {}
87 const languages = buildLanguages()
88 Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
90 Object.assign(serverKeys, languageKeys)
92 writeAll().catch(err => {
97 async function writeAll () {
98 const localePath = join(__dirname, '../../../client/src/locale')
100 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
101 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
103 for (const key of Object.keys(I18N_LOCALES)) {
104 const playerJsonPath = join(localePath, `player.${key}.json`)
105 const translatedPlayer = require(playerJsonPath)
107 const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
108 await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
110 const serverJsonPath = join(localePath, `server.${key}.json`)
111 const translatedServer = require(serverJsonPath)
113 const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
114 await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })