]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - scripts/i18n/create-custom-files.ts
298eda71b4fd8c53f6196530ca0d072d296a3e3d
[github/Chocobozzz/PeerTube.git] / scripts / i18n / create-custom-files.ts
1 import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2 import { writeJSON } from 'fs-extra'
3 import { join } from 'path'
4 import {
5 buildLanguages,
6 VIDEO_CATEGORIES,
7 VIDEO_IMPORT_STATES,
8 VIDEO_LICENCES,
9 VIDEO_PLAYLIST_PRIVACIES,
10 VIDEO_PLAYLIST_TYPES,
11 VIDEO_PRIVACIES,
12 VIDEO_STATES
13 } from '../../server/initializers/constants'
14 import { values } from 'lodash'
15
16 registerTSPaths()
17
18 const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
19 const playerKeys = {
20 'Quality': 'Quality',
21 'Auto': 'Auto',
22 'Speed': 'Speed',
23 'Subtitles/CC': 'Subtitles/CC',
24 'peers': 'peers',
25 'peer': 'peer',
26 'Go to the video page': 'Go to the video page',
27 'Settings': 'Settings',
28 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
29 'Copy the video URL': 'Copy the video URL',
30 'Copy the video URL at the current time': 'Copy the video URL at the current time',
31 'Copy embed code': 'Copy embed code',
32 'Copy magnet URI': 'Copy magnet URI',
33 'Total downloaded: ': 'Total downloaded: ',
34 'Total uploaded: ': 'Total uploaded: '
35 }
36 Object.assign(playerKeys, videojs)
37
38 // Server keys
39 const serverKeys: any = {}
40 values(VIDEO_CATEGORIES)
41 .concat(values(VIDEO_LICENCES))
42 .concat(values(VIDEO_PRIVACIES))
43 .concat(values(VIDEO_STATES))
44 .concat(values(VIDEO_IMPORT_STATES))
45 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
46 .concat(values(VIDEO_PLAYLIST_TYPES))
47 .concat([
48 'This video does not exist.',
49 'We cannot fetch the video. Please try again later.',
50 'Sorry',
51 'This video is not available because the remote instance is not responding.',
52 'This playlist does not exist',
53 'We cannot fetch the playlist. Please try again later.'
54 ])
55 .forEach(v => { serverKeys[v] = v })
56
57 // More keys
58 Object.assign(serverKeys, {
59 Misc: 'Misc',
60 Unknown: 'Unknown'
61 })
62
63 // ISO 639 keys
64 const languageKeys: any = {}
65 const languages = buildLanguages()
66 Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
67
68 Object.assign(serverKeys, languageKeys)
69
70 Promise.all([
71 writeJSON(join(__dirname, '../../../client/src/locale/player.en-US.json'), playerKeys),
72 writeJSON(join(__dirname, '../../../client/src/locale/server.en-US.json'), serverKeys)
73 ]).catch(err => {
74 console.error(err)
75 process.exit(-1)
76 })