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