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