1 import { writeJSON } from 'fs-extra'
2 import { join } from 'path'
3 import { root } from '@shared/core-utils'
9 VIDEO_PLAYLIST_PRIVACIES,
13 } from '../../server/initializers/constants'
14 import { I18N_LOCALES } from '../../shared/core-utils/i18n'
16 const videojs = require(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json'))
21 'Subtitles/CC': 'Subtitles/CC',
24 'Go to the video page': 'Go to the video page',
25 'Settings': 'Settings',
26 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
27 'Copy the video URL': 'Copy the video URL',
28 'Copy the video URL at the current time': 'Copy the video URL at the current time',
29 'Copy embed code': 'Copy embed code',
30 'Copy magnet URI': 'Copy magnet URI',
31 'Total downloaded: ': 'Total downloaded: ',
32 'Total uploaded: ': 'Total uploaded: ',
33 'From servers: ': 'From servers: ',
34 'From peers: ': 'From peers: ',
35 'Normal mode': 'Normal mode',
36 'Stats for nerds': 'Stats for nerds',
37 'Theater mode': 'Theater mode',
38 'Video UUID': 'Video UUID',
39 'Viewport / Frames': 'Viewport / Frames',
40 'Resolution': 'Resolution',
44 'Connection Speed': 'Connection Speed',
45 'Network Activity': 'Network Activity',
46 'Total Transfered': 'Total Transfered',
47 'Download Breakdown': 'Download Breakdown',
48 'Buffer Progress': 'Buffer Progress',
49 'Buffer State': 'Buffer State',
50 'Live Latency': 'Live Latency',
52 '{1} seconds': '{1} seconds',
54 'Playlist: {1}': 'Playlist: {1}',
55 'disabled': 'disabled',
57 'Player mode': 'Player mode',
58 'Play in loop': 'Play in loop',
59 'This live has not started yet.': 'This live has not started yet.',
60 'This live has ended.': 'This live has ended.',
61 'The video failed to play, will try to fast forward.': 'The video failed to play, will try to fast forward.',
62 '{1} / {2} dropped of {3}': '{1} / {2} dropped of {3}',
63 ' (muted)': ' (muted)',
64 '{1} from servers · {2} from peers': '{1} from servers · {2} from peers'
66 Object.assign(playerKeys, videojs)
69 const serverKeys: any = {}
70 Object.values(VIDEO_CATEGORIES)
71 .concat(Object.values(VIDEO_LICENCES))
72 .concat(Object.values(VIDEO_PRIVACIES))
73 .concat(Object.values(VIDEO_STATES))
74 .concat(Object.values(VIDEO_IMPORT_STATES))
75 .concat(Object.values(VIDEO_PLAYLIST_PRIVACIES))
76 .concat(Object.values(VIDEO_PLAYLIST_TYPES))
78 'This video does not exist.',
79 'We cannot fetch the video. Please try again later.',
81 'This video is not available because the remote instance is not responding.',
82 'This playlist does not exist',
83 'We cannot fetch the playlist. Please try again later.',
88 .forEach(v => { serverKeys[v] = v })
91 Object.assign(serverKeys, {
97 const languageKeys: any = {}
98 const languages = buildLanguages()
99 Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
101 Object.assign(serverKeys, languageKeys)
103 writeAll().catch(err => {
108 async function writeAll () {
109 const localePath = join(root(), 'client', 'src', 'locale')
111 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
112 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
114 for (const key of Object.keys(I18N_LOCALES)) {
115 const playerJsonPath = join(localePath, `player.${key}.json`)
116 const translatedPlayer = require(playerJsonPath)
118 const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
119 await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
121 const serverJsonPath = join(localePath, `server.${key}.json`)
122 const translatedServer = require(serverJsonPath)
124 const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
125 await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })