2019-11-07 02:45:14 -06:00
|
|
|
import { writeJSON } from 'fs-extra'
|
2020-08-14 02:32:20 -05:00
|
|
|
import { values } from 'lodash'
|
2018-06-06 07:23:40 -05:00
|
|
|
import { join } from 'path'
|
2020-08-14 02:32:20 -05:00
|
|
|
import { registerTSPaths } from '../../server/helpers/register-ts-paths'
|
2018-08-03 03:26:47 -05:00
|
|
|
import {
|
|
|
|
buildLanguages,
|
|
|
|
VIDEO_CATEGORIES,
|
|
|
|
VIDEO_IMPORT_STATES,
|
2019-11-07 02:45:14 -06:00
|
|
|
VIDEO_LICENCES,
|
|
|
|
VIDEO_PLAYLIST_PRIVACIES,
|
|
|
|
VIDEO_PLAYLIST_TYPES,
|
2018-08-03 03:26:47 -05:00
|
|
|
VIDEO_PRIVACIES,
|
|
|
|
VIDEO_STATES
|
|
|
|
} from '../../server/initializers/constants'
|
2020-08-14 02:32:20 -05:00
|
|
|
import { I18N_LOCALES } from '../../shared/core-utils/i18n'
|
2018-06-06 07:23:40 -05:00
|
|
|
|
2019-11-07 02:45:14 -06:00
|
|
|
registerTSPaths()
|
2018-06-06 07:23:40 -05:00
|
|
|
|
2019-11-07 02:45:14 -06:00
|
|
|
const videojs = require(join(__dirname, '../../../client/src/locale/videojs.en-US.json'))
|
2018-06-06 07:23:40 -05:00
|
|
|
const playerKeys = {
|
|
|
|
'Quality': 'Quality',
|
|
|
|
'Auto': 'Auto',
|
|
|
|
'Speed': 'Speed',
|
2018-07-13 11:21:19 -05:00
|
|
|
'Subtitles/CC': 'Subtitles/CC',
|
2018-06-06 07:23:40 -05:00
|
|
|
'peers': 'peers',
|
2019-01-29 01:37:25 -06:00
|
|
|
'peer': 'peer',
|
2018-06-06 07:23:40 -05:00
|
|
|
'Go to the video page': 'Go to the video page',
|
|
|
|
'Settings': 'Settings',
|
2020-07-20 10:05:08 -05:00
|
|
|
'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
|
2018-06-06 07:23:40 -05:00
|
|
|
'Copy the video URL': 'Copy the video URL',
|
|
|
|
'Copy the video URL at the current time': 'Copy the video URL at the current time',
|
2019-01-29 01:37:25 -06:00
|
|
|
'Copy embed code': 'Copy embed code',
|
2019-02-15 03:57:59 -06:00
|
|
|
'Copy magnet URI': 'Copy magnet URI',
|
2019-01-29 01:37:25 -06:00
|
|
|
'Total downloaded: ': 'Total downloaded: ',
|
|
|
|
'Total uploaded: ': 'Total uploaded: '
|
2018-06-06 07:23:40 -05:00
|
|
|
}
|
2019-11-07 02:45:14 -06:00
|
|
|
Object.assign(playerKeys, videojs)
|
2018-06-06 07:23:40 -05:00
|
|
|
|
2018-06-06 09:46:42 -05:00
|
|
|
// Server keys
|
|
|
|
const serverKeys: any = {}
|
|
|
|
values(VIDEO_CATEGORIES)
|
|
|
|
.concat(values(VIDEO_LICENCES))
|
|
|
|
.concat(values(VIDEO_PRIVACIES))
|
2018-08-03 03:26:47 -05:00
|
|
|
.concat(values(VIDEO_STATES))
|
|
|
|
.concat(values(VIDEO_IMPORT_STATES))
|
2019-03-06 08:36:44 -06:00
|
|
|
.concat(values(VIDEO_PLAYLIST_PRIVACIES))
|
|
|
|
.concat(values(VIDEO_PLAYLIST_TYPES))
|
2019-01-14 10:45:02 -06:00
|
|
|
.concat([
|
|
|
|
'This video does not exist.',
|
|
|
|
'We cannot fetch the video. Please try again later.',
|
|
|
|
'Sorry',
|
2020-08-04 04:42:06 -05:00
|
|
|
'This video is not available because the remote instance is not responding.',
|
|
|
|
'This playlist does not exist',
|
2020-08-05 02:44:58 -05:00
|
|
|
'We cannot fetch the playlist. Please try again later.',
|
|
|
|
'Playlist: {1}',
|
2020-08-05 04:41:22 -05:00
|
|
|
'By {1}',
|
|
|
|
'Unavailable video'
|
2019-01-14 10:45:02 -06:00
|
|
|
])
|
2020-07-30 07:54:31 -05:00
|
|
|
.forEach(v => { serverKeys[v] = v })
|
2018-06-06 09:46:42 -05:00
|
|
|
|
|
|
|
// More keys
|
|
|
|
Object.assign(serverKeys, {
|
2020-07-30 07:54:31 -05:00
|
|
|
Misc: 'Misc',
|
|
|
|
Unknown: 'Unknown'
|
2018-06-06 09:46:42 -05:00
|
|
|
})
|
|
|
|
|
2018-06-13 08:55:13 -05:00
|
|
|
// ISO 639 keys
|
|
|
|
const languageKeys: any = {}
|
|
|
|
const languages = buildLanguages()
|
2020-07-30 07:54:31 -05:00
|
|
|
Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
|
2018-06-13 08:55:13 -05:00
|
|
|
|
2019-11-07 02:45:14 -06:00
|
|
|
Object.assign(serverKeys, languageKeys)
|
2018-06-13 08:55:13 -05:00
|
|
|
|
2020-08-14 02:32:20 -05:00
|
|
|
writeAll().catch(err => {
|
2018-06-06 09:46:42 -05:00
|
|
|
console.error(err)
|
|
|
|
process.exit(-1)
|
2019-11-07 02:45:14 -06:00
|
|
|
})
|
2020-08-14 02:32:20 -05:00
|
|
|
|
|
|
|
async function writeAll () {
|
|
|
|
const localePath = join(__dirname, '../../../client/src/locale')
|
|
|
|
|
|
|
|
await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
|
|
|
|
await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
|
|
|
|
|
|
|
|
for (const key of Object.keys(I18N_LOCALES)) {
|
|
|
|
const playerJsonPath = join(localePath, `player.${key}.json`)
|
|
|
|
const translatedPlayer = require(playerJsonPath)
|
|
|
|
|
|
|
|
const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
|
|
|
|
await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
|
|
|
|
|
|
|
|
const serverJsonPath = join(localePath, `server.${key}.json`)
|
|
|
|
const translatedServer = require(serverJsonPath)
|
|
|
|
|
|
|
|
const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
|
|
|
|
await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
|
|
|
|
}
|
|
|
|
}
|