2023-07-31 08:34:36 -04:00
|
|
|
import { readJsonSync, writeJSON } from 'fs-extra/esm'
|
2018-06-06 08:23:40 -04:00
|
|
|
import { join } from 'path'
|
2023-07-31 08:34:36 -04:00
|
|
|
import { I18N_LOCALES, USER_ROLE_LABELS } from '@peertube/peertube-core-utils'
|
|
|
|
import { root } from '@peertube/peertube-node-utils'
|
2018-08-03 04:26:47 -04:00
|
|
|
import {
|
2023-04-21 09:04:12 -04:00
|
|
|
ABUSE_STATES,
|
2018-08-03 04:26:47 -04:00
|
|
|
buildLanguages,
|
2023-04-21 09:04:12 -04:00
|
|
|
RUNNER_JOB_STATES,
|
|
|
|
USER_REGISTRATION_STATES,
|
2018-08-03 04:26:47 -04:00
|
|
|
VIDEO_CATEGORIES,
|
2023-04-21 09:04:12 -04:00
|
|
|
VIDEO_CHANNEL_SYNC_STATE,
|
2018-08-03 04:26:47 -04:00
|
|
|
VIDEO_IMPORT_STATES,
|
2019-11-07 03:45:14 -05:00
|
|
|
VIDEO_LICENCES,
|
|
|
|
VIDEO_PLAYLIST_PRIVACIES,
|
|
|
|
VIDEO_PLAYLIST_TYPES,
|
2018-08-03 04:26:47 -04:00
|
|
|
VIDEO_PRIVACIES,
|
|
|
|
VIDEO_STATES
|
2023-10-04 09:13:25 -04:00
|
|
|
} from '@peertube/peertube-server/core/initializers/constants.js'
|
2018-06-06 08:23:40 -04:00
|
|
|
|
2023-07-31 08:34:36 -04:00
|
|
|
const videojs = readJsonSync(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json'))
|
2018-06-06 08:23:40 -04:00
|
|
|
const playerKeys = {
|
|
|
|
'Quality': 'Quality',
|
|
|
|
'Auto': 'Auto',
|
|
|
|
'Speed': 'Speed',
|
2018-07-13 12:21:19 -04:00
|
|
|
'Subtitles/CC': 'Subtitles/CC',
|
2018-06-06 08:23:40 -04:00
|
|
|
'peers': 'peers',
|
2019-01-29 02:37:25 -05:00
|
|
|
'peer': 'peer',
|
2018-06-06 08:23:40 -04:00
|
|
|
'Go to the video page': 'Go to the video page',
|
|
|
|
'Settings': 'Settings',
|
2020-07-20 11:05:08 -04:00
|
|
|
'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
|
2018-06-06 08:23:40 -04: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',
|
2021-04-21 09:28:12 -04:00
|
|
|
'Copy embed code': 'Copy embed code',
|
2019-02-15 04:57:59 -05:00
|
|
|
'Copy magnet URI': 'Copy magnet URI',
|
2019-01-29 02:37:25 -05:00
|
|
|
'Total downloaded: ': 'Total downloaded: ',
|
2020-11-09 10:29:58 -05:00
|
|
|
'Total uploaded: ': 'Total uploaded: ',
|
2020-12-04 10:37:21 -05:00
|
|
|
'From servers: ': 'From servers: ',
|
|
|
|
'From peers: ': 'From peers: ',
|
2020-11-09 10:29:58 -05:00
|
|
|
'Normal mode': 'Normal mode',
|
2021-04-27 09:50:29 -04:00
|
|
|
'Stats for nerds': 'Stats for nerds',
|
|
|
|
'Theater mode': 'Theater mode',
|
|
|
|
'Video UUID': 'Video UUID',
|
|
|
|
'Viewport / Frames': 'Viewport / Frames',
|
|
|
|
'Resolution': 'Resolution',
|
|
|
|
'Volume': 'Volume',
|
|
|
|
'Codecs': 'Codecs',
|
|
|
|
'Color': 'Color',
|
2022-12-20 10:28:15 -05:00
|
|
|
'Go back to the live': 'Go back to the live',
|
2021-04-27 09:50:29 -04:00
|
|
|
'Connection Speed': 'Connection Speed',
|
|
|
|
'Network Activity': 'Network Activity',
|
|
|
|
'Total Transfered': 'Total Transfered',
|
|
|
|
'Download Breakdown': 'Download Breakdown',
|
|
|
|
'Buffer Progress': 'Buffer Progress',
|
|
|
|
'Buffer State': 'Buffer State',
|
2021-04-28 03:07:57 -04:00
|
|
|
'Live Latency': 'Live Latency',
|
2021-12-15 10:25:33 -05:00
|
|
|
'P2P': 'P2P',
|
2022-01-12 09:07:21 -05:00
|
|
|
'{1} seconds': '{1} seconds',
|
2021-12-15 10:25:33 -05:00
|
|
|
'enabled': 'enabled',
|
2022-01-12 09:07:21 -05:00
|
|
|
'Playlist: {1}': 'Playlist: {1}',
|
2021-12-15 10:25:33 -05:00
|
|
|
'disabled': 'disabled',
|
2021-10-21 05:01:10 -04:00
|
|
|
' off': ' off',
|
2022-02-02 05:16:23 -05:00
|
|
|
'Player mode': 'Player mode',
|
2022-05-04 03:18:39 -04:00
|
|
|
'Play in loop': 'Play in loop',
|
2022-05-31 08:34:47 -04:00
|
|
|
'This live has not started yet.': 'This live has not started yet.',
|
|
|
|
'This live has ended.': 'This live has ended.',
|
2022-09-16 05:10:12 -04:00
|
|
|
'The video failed to play, will try to fast forward.': 'The video failed to play, will try to fast forward.',
|
|
|
|
'{1} / {2} dropped of {3}': '{1} / {2} dropped of {3}',
|
|
|
|
' (muted)': ' (muted)',
|
2023-02-13 09:57:08 -05:00
|
|
|
'{1} from servers · {2} from peers': '{1} from servers · {2} from peers',
|
|
|
|
'Previous video': 'Previous video',
|
2023-02-15 04:27:26 -05:00
|
|
|
'Video page (new window)': 'Video page (new window)',
|
2023-06-29 03:48:55 -04:00
|
|
|
'Next video': 'Next video',
|
|
|
|
'This video is password protected': 'This video is password protected',
|
|
|
|
'You need a password to watch this video.': 'You need a password to watch this video.',
|
2023-06-29 09:55:00 -04:00
|
|
|
'Incorrect password, please enter a correct password': 'Incorrect password, please enter a correct password',
|
|
|
|
'Cancel': 'Cancel',
|
|
|
|
'Up Next': 'Up Next',
|
|
|
|
'Autoplay is suspended': 'Autoplay is suspended'
|
2018-06-06 08:23:40 -04:00
|
|
|
}
|
2019-11-07 03:45:14 -05:00
|
|
|
Object.assign(playerKeys, videojs)
|
2018-06-06 08:23:40 -04:00
|
|
|
|
2018-06-06 10:46:42 -04:00
|
|
|
// Server keys
|
|
|
|
const serverKeys: any = {}
|
2022-08-17 09:36:03 -04:00
|
|
|
Object.values(VIDEO_CATEGORIES)
|
|
|
|
.concat(Object.values(VIDEO_LICENCES))
|
|
|
|
.concat(Object.values(VIDEO_PRIVACIES))
|
|
|
|
.concat(Object.values(VIDEO_STATES))
|
|
|
|
.concat(Object.values(VIDEO_IMPORT_STATES))
|
|
|
|
.concat(Object.values(VIDEO_PLAYLIST_PRIVACIES))
|
|
|
|
.concat(Object.values(VIDEO_PLAYLIST_TYPES))
|
2023-04-17 02:49:52 -04:00
|
|
|
.concat(Object.values(USER_ROLE_LABELS))
|
2023-04-21 09:04:12 -04:00
|
|
|
.concat(Object.values(VIDEO_CHANNEL_SYNC_STATE))
|
|
|
|
.concat(Object.values(ABUSE_STATES))
|
|
|
|
.concat(Object.values(USER_REGISTRATION_STATES))
|
|
|
|
.concat(Object.values(RUNNER_JOB_STATES))
|
2019-01-14 11:45:02 -05:00
|
|
|
.concat([
|
|
|
|
'This video does not exist.',
|
|
|
|
'We cannot fetch the video. Please try again later.',
|
|
|
|
'Sorry',
|
2020-08-04 05:42:06 -04:00
|
|
|
'This video is not available because the remote instance is not responding.',
|
|
|
|
'This playlist does not exist',
|
2020-08-05 03:44:58 -04:00
|
|
|
'We cannot fetch the playlist. Please try again later.',
|
|
|
|
'Playlist: {1}',
|
2020-08-05 05:41:22 -04:00
|
|
|
'By {1}',
|
2020-11-09 10:29:58 -05:00
|
|
|
'Unavailable video'
|
2019-01-14 11:45:02 -05:00
|
|
|
])
|
2020-07-30 08:54:31 -04:00
|
|
|
.forEach(v => { serverKeys[v] = v })
|
2018-06-06 10:46:42 -04:00
|
|
|
|
|
|
|
// More keys
|
|
|
|
Object.assign(serverKeys, {
|
2020-07-30 08:54:31 -04:00
|
|
|
Unknown: 'Unknown'
|
2018-06-06 10:46:42 -04:00
|
|
|
})
|
|
|
|
|
2018-06-13 09:55:13 -04:00
|
|
|
// ISO 639 keys
|
|
|
|
const languageKeys: any = {}
|
|
|
|
const languages = buildLanguages()
|
2020-07-30 08:54:31 -04:00
|
|
|
Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
|
2018-06-13 09:55:13 -04:00
|
|
|
|
2019-11-07 03:45:14 -05:00
|
|
|
Object.assign(serverKeys, languageKeys)
|
2018-06-13 09:55:13 -04:00
|
|
|
|
2020-08-14 03:32:20 -04:00
|
|
|
writeAll().catch(err => {
|
2018-06-06 10:46:42 -04:00
|
|
|
console.error(err)
|
|
|
|
process.exit(-1)
|
2019-11-07 03:45:14 -05:00
|
|
|
})
|
2020-08-14 03:32:20 -04:00
|
|
|
|
|
|
|
async function writeAll () {
|
2022-01-03 11:13:11 -05:00
|
|
|
const localePath = join(root(), 'client', 'src', 'locale')
|
2020-08-14 03:32:20 -04:00
|
|
|
|
|
|
|
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`)
|
2023-07-31 08:34:36 -04:00
|
|
|
const translatedPlayer = readJsonSync(playerJsonPath)
|
2020-08-14 03:32:20 -04:00
|
|
|
|
|
|
|
const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
|
|
|
|
await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
|
|
|
|
|
|
|
|
const serverJsonPath = join(localePath, `server.${key}.json`)
|
2023-07-31 08:34:36 -04:00
|
|
|
const translatedServer = readJsonSync(serverJsonPath)
|
2020-08-14 03:32:20 -04:00
|
|
|
|
|
|
|
const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
|
|
|
|
await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
|
|
|
|
}
|
|
|
|
}
|