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