]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - scripts/i18n/create-custom-files.ts
Remove unnecessary function
[github/Chocobozzz/PeerTube.git] / scripts / i18n / create-custom-files.ts
... / ...
CommitLineData
1import { writeJSON } from 'fs-extra'
2import { values } from 'lodash'
3import { join } from 'path'
4import { root } from '@shared/core-utils'
5import {
6 buildLanguages,
7 VIDEO_CATEGORIES,
8 VIDEO_IMPORT_STATES,
9 VIDEO_LICENCES,
10 VIDEO_PLAYLIST_PRIVACIES,
11 VIDEO_PLAYLIST_TYPES,
12 VIDEO_PRIVACIES,
13 VIDEO_STATES
14} from '../../server/initializers/constants'
15import { I18N_LOCALES } from '../../shared/core-utils/i18n'
16
17const videojs = require(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json'))
18const playerKeys = {
19 'Quality': 'Quality',
20 'Auto': 'Auto',
21 'Speed': 'Speed',
22 'Subtitles/CC': 'Subtitles/CC',
23 'peers': 'peers',
24 'peer': 'peer',
25 'Go to the video page': 'Go to the video page',
26 'Settings': 'Settings',
27 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
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',
30 'Copy embed code': 'Copy embed code',
31 'Copy magnet URI': 'Copy magnet URI',
32 'Total downloaded: ': 'Total downloaded: ',
33 'Total uploaded: ': 'Total uploaded: ',
34 'From servers: ': 'From servers: ',
35 'From peers: ': 'From peers: ',
36 'Normal mode': 'Normal mode',
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',
51 'Live Latency': 'Live Latency',
52 'P2P': 'P2P',
53 '{1} seconds': '{1} seconds',
54 'enabled': 'enabled',
55 'Playlist: {1}': 'Playlist: {1}',
56 'disabled': 'disabled',
57 ' off': ' off',
58 'Player mode': 'Player mode'
59}
60Object.assign(playerKeys, videojs)
61
62// Server keys
63const serverKeys: any = {}
64values(VIDEO_CATEGORIES)
65 .concat(values(VIDEO_LICENCES))
66 .concat(values(VIDEO_PRIVACIES))
67 .concat(values(VIDEO_STATES))
68 .concat(values(VIDEO_IMPORT_STATES))
69 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
70 .concat(values(VIDEO_PLAYLIST_TYPES))
71 .concat([
72 'This video does not exist.',
73 'We cannot fetch the video. Please try again later.',
74 'Sorry',
75 'This video is not available because the remote instance is not responding.',
76 'This playlist does not exist',
77 'We cannot fetch the playlist. Please try again later.',
78 'Playlist: {1}',
79 'By {1}',
80 'Unavailable video'
81 ])
82 .forEach(v => { serverKeys[v] = v })
83
84// More keys
85Object.assign(serverKeys, {
86 Misc: 'Misc',
87 Unknown: 'Unknown'
88})
89
90// ISO 639 keys
91const languageKeys: any = {}
92const languages = buildLanguages()
93Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
94
95Object.assign(serverKeys, languageKeys)
96
97writeAll().catch(err => {
98 console.error(err)
99 process.exit(-1)
100})
101
102async function writeAll () {
103 const localePath = join(root(), '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}