]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/i18n/create-custom-files.ts
Move video alert in a dedicated component
[github/Chocobozzz/PeerTube.git] / scripts / i18n / create-custom-files.ts
CommitLineData
3aea8eb2 1import { writeJSON } from 'fs-extra'
ef78fdbb 2import { values } from 'lodash'
e945b184 3import { join } from 'path'
ef78fdbb 4import { registerTSPaths } from '../../server/helpers/register-ts-paths'
7e5f9f00
C
5import {
6 buildLanguages,
7 VIDEO_CATEGORIES,
8 VIDEO_IMPORT_STATES,
3aea8eb2
C
9 VIDEO_LICENCES,
10 VIDEO_PLAYLIST_PRIVACIES,
11 VIDEO_PLAYLIST_TYPES,
7e5f9f00
C
12 VIDEO_PRIVACIES,
13 VIDEO_STATES
14} from '../../server/initializers/constants'
ef78fdbb 15import { I18N_LOCALES } from '../../shared/core-utils/i18n'
e945b184 16
3aea8eb2 17registerTSPaths()
e945b184 18
3aea8eb2 19const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
e945b184
C
20const playerKeys = {
21 'Quality': 'Quality',
22 'Auto': 'Auto',
23 'Speed': 'Speed',
16f7022b 24 'Subtitles/CC': 'Subtitles/CC',
e945b184 25 'peers': 'peers',
09209296 26 'peer': 'peer',
e945b184
C
27 'Go to the video page': 'Go to the video page',
28 'Settings': 'Settings',
d28d1358 29 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
e945b184
C
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',
3e0e8d4a 32 'Copy embed code': 'Copy embed code',
37c6bb36 33 'Copy magnet URI': 'Copy magnet URI',
09209296 34 'Total downloaded: ': 'Total downloaded: ',
c1961762 35 'Total uploaded: ': 'Total uploaded: ',
5f8327c5
C
36 'From servers: ': 'From servers: ',
37 'From peers: ': 'From peers: ',
c1961762 38 'Normal mode': 'Normal mode',
4e11d8f3
C
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',
44 'Volume': 'Volume',
45 'Codecs': 'Codecs',
46 'Color': 'Color',
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',
a45050e0
C
53 'Live Latency': 'Live Latency',
54 'Player mode': 'Player mode'
e945b184 55}
3aea8eb2 56Object.assign(playerKeys, videojs)
e945b184 57
7ce44a74
C
58// Server keys
59const serverKeys: any = {}
60values(VIDEO_CATEGORIES)
61 .concat(values(VIDEO_LICENCES))
62 .concat(values(VIDEO_PRIVACIES))
7e5f9f00
C
63 .concat(values(VIDEO_STATES))
64 .concat(values(VIDEO_IMPORT_STATES))
830b4faf
C
65 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
66 .concat(values(VIDEO_PLAYLIST_TYPES))
ad3fa0c5
C
67 .concat([
68 'This video does not exist.',
69 'We cannot fetch the video. Please try again later.',
70 'Sorry',
5abc96fc
C
71 'This video is not available because the remote instance is not responding.',
72 'This playlist does not exist',
4572c3d0
C
73 'We cannot fetch the playlist. Please try again later.',
74 'Playlist: {1}',
56674bb9 75 'By {1}',
c1961762 76 'Unavailable video'
ad3fa0c5 77 ])
f0af38e6 78 .forEach(v => { serverKeys[v] = v })
7ce44a74 79
7ce44a74
C
80// More keys
81Object.assign(serverKeys, {
f0af38e6
C
82 Misc: 'Misc',
83 Unknown: 'Unknown'
7ce44a74
C
84})
85
850c1bf7
C
86// ISO 639 keys
87const languageKeys: any = {}
88const languages = buildLanguages()
f0af38e6 89Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
850c1bf7 90
3aea8eb2 91Object.assign(serverKeys, languageKeys)
850c1bf7 92
ef78fdbb 93writeAll().catch(err => {
7ce44a74
C
94 console.error(err)
95 process.exit(-1)
3aea8eb2 96})
ef78fdbb
C
97
98async function writeAll () {
99 const localePath = join(__dirname, '../../../client/src/locale')
100
101 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
102 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
103
104 for (const key of Object.keys(I18N_LOCALES)) {
105 const playerJsonPath = join(localePath, `player.${key}.json`)
106 const translatedPlayer = require(playerJsonPath)
107
108 const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
109 await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
110
111 const serverJsonPath = join(localePath, `server.${key}.json`)
112 const translatedServer = require(serverJsonPath)
113
114 const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
115 await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
116 }
117}