]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/i18n/create-custom-files.ts
Updated notification types in openapi reference
[github/Chocobozzz/PeerTube.git] / scripts / i18n / create-custom-files.ts
CommitLineData
42fea41a
C
1import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2registerTSPaths()
3
3aea8eb2 4import { writeJSON } from 'fs-extra'
ef78fdbb 5import { values } from 'lodash'
e945b184 6import { join } from 'path'
7e5f9f00
C
7import {
8 buildLanguages,
9 VIDEO_CATEGORIES,
10 VIDEO_IMPORT_STATES,
3aea8eb2
C
11 VIDEO_LICENCES,
12 VIDEO_PLAYLIST_PRIVACIES,
13 VIDEO_PLAYLIST_TYPES,
7e5f9f00
C
14 VIDEO_PRIVACIES,
15 VIDEO_STATES
16} from '../../server/initializers/constants'
ef78fdbb 17import { I18N_LOCALES } from '../../shared/core-utils/i18n'
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 53 'Live Latency': 'Live Latency',
95765067
C
54 'P2P': 'P2P',
55 'enabled': 'enabled',
56 'disabled': 'disabled',
efcadd3d 57 ' off': ' off',
a45050e0 58 'Player mode': 'Player mode'
e945b184 59}
3aea8eb2 60Object.assign(playerKeys, videojs)
e945b184 61
7ce44a74
C
62// Server keys
63const serverKeys: any = {}
64values(VIDEO_CATEGORIES)
65 .concat(values(VIDEO_LICENCES))
66 .concat(values(VIDEO_PRIVACIES))
7e5f9f00
C
67 .concat(values(VIDEO_STATES))
68 .concat(values(VIDEO_IMPORT_STATES))
830b4faf
C
69 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
70 .concat(values(VIDEO_PLAYLIST_TYPES))
ad3fa0c5
C
71 .concat([
72 'This video does not exist.',
73 'We cannot fetch the video. Please try again later.',
74 'Sorry',
5abc96fc
C
75 'This video is not available because the remote instance is not responding.',
76 'This playlist does not exist',
4572c3d0
C
77 'We cannot fetch the playlist. Please try again later.',
78 'Playlist: {1}',
56674bb9 79 'By {1}',
c1961762 80 'Unavailable video'
ad3fa0c5 81 ])
f0af38e6 82 .forEach(v => { serverKeys[v] = v })
7ce44a74 83
7ce44a74
C
84// More keys
85Object.assign(serverKeys, {
f0af38e6
C
86 Misc: 'Misc',
87 Unknown: 'Unknown'
7ce44a74
C
88})
89
850c1bf7
C
90// ISO 639 keys
91const languageKeys: any = {}
92const languages = buildLanguages()
f0af38e6 93Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
850c1bf7 94
3aea8eb2 95Object.assign(serverKeys, languageKeys)
850c1bf7 96
ef78fdbb 97writeAll().catch(err => {
7ce44a74
C
98 console.error(err)
99 process.exit(-1)
3aea8eb2 100})
ef78fdbb
C
101
102async function writeAll () {
103 const localePath = join(__dirname, '../../../client/src/locale')
104
105 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
106 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
107
108 for (const key of Object.keys(I18N_LOCALES)) {
109 const playerJsonPath = join(localePath, `player.${key}.json`)
110 const translatedPlayer = require(playerJsonPath)
111
112 const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
113 await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
114
115 const serverJsonPath = join(localePath, `server.${key}.json`)
116 const translatedServer = require(serverJsonPath)
117
118 const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
119 await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
120 }
121}