]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - scripts/i18n/create-custom-files.ts
Use playlistPosition for playlists instead of videoId
[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 { registerTSPaths } from '../../server/helpers/register-ts-paths'
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
17registerTSPaths()
18
19const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
20const playerKeys = {
21 'Quality': 'Quality',
22 'Auto': 'Auto',
23 'Speed': 'Speed',
24 'Subtitles/CC': 'Subtitles/CC',
25 'peers': 'peers',
26 'peer': 'peer',
27 'Go to the video page': 'Go to the video page',
28 'Settings': 'Settings',
29 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
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',
32 'Copy embed code': 'Copy embed code',
33 'Copy magnet URI': 'Copy magnet URI',
34 'Total downloaded: ': 'Total downloaded: ',
35 'Total uploaded: ': 'Total uploaded: '
36}
37Object.assign(playerKeys, videojs)
38
39// Server keys
40const serverKeys: any = {}
41values(VIDEO_CATEGORIES)
42 .concat(values(VIDEO_LICENCES))
43 .concat(values(VIDEO_PRIVACIES))
44 .concat(values(VIDEO_STATES))
45 .concat(values(VIDEO_IMPORT_STATES))
46 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
47 .concat(values(VIDEO_PLAYLIST_TYPES))
48 .concat([
49 'This video does not exist.',
50 'We cannot fetch the video. Please try again later.',
51 'Sorry',
52 'This video is not available because the remote instance is not responding.',
53 'This playlist does not exist',
54 'We cannot fetch the playlist. Please try again later.',
55 'Playlist: {1}',
56 'By {1}',
57 'Unavailable video'
58 ])
59 .forEach(v => { serverKeys[v] = v })
60
61// More keys
62Object.assign(serverKeys, {
63 Misc: 'Misc',
64 Unknown: 'Unknown'
65})
66
67// ISO 639 keys
68const languageKeys: any = {}
69const languages = buildLanguages()
70Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
71
72Object.assign(serverKeys, languageKeys)
73
74writeAll().catch(err => {
75 console.error(err)
76 process.exit(-1)
77})
78
79async function writeAll () {
80 const localePath = join(__dirname, '../../../client/src/locale')
81
82 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
83 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
84
85 for (const key of Object.keys(I18N_LOCALES)) {
86 const playerJsonPath = join(localePath, `player.${key}.json`)
87 const translatedPlayer = require(playerJsonPath)
88
89 const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
90 await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
91
92 const serverJsonPath = join(localePath, `server.${key}.json`)
93 const translatedServer = require(serverJsonPath)
94
95 const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
96 await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
97 }
98}