]>
Commit | Line | Data |
---|---|---|
3aea8eb2 | 1 | import { writeJSON } from 'fs-extra' |
e945b184 | 2 | import { join } from 'path' |
fee3d77d | 3 | import { root, USER_ROLE_LABELS } from '@shared/core-utils' |
7e5f9f00 | 4 | import { |
e592df48 | 5 | ABUSE_STATES, |
7e5f9f00 | 6 | buildLanguages, |
e592df48 C |
7 | RUNNER_JOB_STATES, |
8 | USER_REGISTRATION_STATES, | |
7e5f9f00 | 9 | VIDEO_CATEGORIES, |
e592df48 | 10 | VIDEO_CHANNEL_SYNC_STATE, |
7e5f9f00 | 11 | VIDEO_IMPORT_STATES, |
3aea8eb2 C |
12 | VIDEO_LICENCES, |
13 | VIDEO_PLAYLIST_PRIVACIES, | |
14 | VIDEO_PLAYLIST_TYPES, | |
7e5f9f00 C |
15 | VIDEO_PRIVACIES, |
16 | VIDEO_STATES | |
17 | } from '../../server/initializers/constants' | |
ef78fdbb | 18 | import { I18N_LOCALES } from '../../shared/core-utils/i18n' |
e945b184 | 19 | |
f8360396 | 20 | const videojs = require(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json')) |
e945b184 C |
21 | const playerKeys = { |
22 | 'Quality': 'Quality', | |
23 | 'Auto': 'Auto', | |
24 | 'Speed': 'Speed', | |
16f7022b | 25 | 'Subtitles/CC': 'Subtitles/CC', |
e945b184 | 26 | 'peers': 'peers', |
09209296 | 27 | 'peer': 'peer', |
e945b184 C |
28 | 'Go to the video page': 'Go to the video page', |
29 | 'Settings': 'Settings', | |
d28d1358 | 30 | 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.', |
e945b184 C |
31 | 'Copy the video URL': 'Copy the video URL', |
32 | 'Copy the video URL at the current time': 'Copy the video URL at the current time', | |
3e0e8d4a | 33 | 'Copy embed code': 'Copy embed code', |
37c6bb36 | 34 | 'Copy magnet URI': 'Copy magnet URI', |
09209296 | 35 | 'Total downloaded: ': 'Total downloaded: ', |
c1961762 | 36 | 'Total uploaded: ': 'Total uploaded: ', |
5f8327c5 C |
37 | 'From servers: ': 'From servers: ', |
38 | 'From peers: ': 'From peers: ', | |
c1961762 | 39 | 'Normal mode': 'Normal mode', |
4e11d8f3 C |
40 | 'Stats for nerds': 'Stats for nerds', |
41 | 'Theater mode': 'Theater mode', | |
42 | 'Video UUID': 'Video UUID', | |
43 | 'Viewport / Frames': 'Viewport / Frames', | |
44 | 'Resolution': 'Resolution', | |
45 | 'Volume': 'Volume', | |
46 | 'Codecs': 'Codecs', | |
47 | 'Color': 'Color', | |
0e7c4b03 | 48 | 'Go back to the live': 'Go back to the live', |
4e11d8f3 C |
49 | 'Connection Speed': 'Connection Speed', |
50 | 'Network Activity': 'Network Activity', | |
51 | 'Total Transfered': 'Total Transfered', | |
52 | 'Download Breakdown': 'Download Breakdown', | |
53 | 'Buffer Progress': 'Buffer Progress', | |
54 | 'Buffer State': 'Buffer State', | |
a45050e0 | 55 | 'Live Latency': 'Live Latency', |
95765067 | 56 | 'P2P': 'P2P', |
2dd0a8a8 | 57 | '{1} seconds': '{1} seconds', |
95765067 | 58 | 'enabled': 'enabled', |
2dd0a8a8 | 59 | 'Playlist: {1}': 'Playlist: {1}', |
95765067 | 60 | 'disabled': 'disabled', |
efcadd3d | 61 | ' off': ' off', |
c4207f97 | 62 | 'Player mode': 'Player mode', |
b003d575 | 63 | 'Play in loop': 'Play in loop', |
b0185d73 C |
64 | 'This live has not started yet.': 'This live has not started yet.', |
65 | 'This live has ended.': 'This live has ended.', | |
6235c0b8 C |
66 | 'The video failed to play, will try to fast forward.': 'The video failed to play, will try to fast forward.', |
67 | '{1} / {2} dropped of {3}': '{1} / {2} dropped of {3}', | |
68 | ' (muted)': ' (muted)', | |
dc3e3c26 C |
69 | '{1} from servers · {2} from peers': '{1} from servers · {2} from peers', |
70 | 'Previous video': 'Previous video', | |
c9c21faf | 71 | 'Video page (new window)': 'Video page (new window)', |
dc3e3c26 | 72 | 'Next video': 'Next video' |
e945b184 | 73 | } |
3aea8eb2 | 74 | Object.assign(playerKeys, videojs) |
e945b184 | 75 | |
7ce44a74 C |
76 | // Server keys |
77 | const serverKeys: any = {} | |
690bb8f9 C |
78 | Object.values(VIDEO_CATEGORIES) |
79 | .concat(Object.values(VIDEO_LICENCES)) | |
80 | .concat(Object.values(VIDEO_PRIVACIES)) | |
81 | .concat(Object.values(VIDEO_STATES)) | |
82 | .concat(Object.values(VIDEO_IMPORT_STATES)) | |
83 | .concat(Object.values(VIDEO_PLAYLIST_PRIVACIES)) | |
84 | .concat(Object.values(VIDEO_PLAYLIST_TYPES)) | |
fee3d77d | 85 | .concat(Object.values(USER_ROLE_LABELS)) |
e592df48 C |
86 | .concat(Object.values(VIDEO_CHANNEL_SYNC_STATE)) |
87 | .concat(Object.values(ABUSE_STATES)) | |
88 | .concat(Object.values(USER_REGISTRATION_STATES)) | |
89 | .concat(Object.values(RUNNER_JOB_STATES)) | |
ad3fa0c5 C |
90 | .concat([ |
91 | 'This video does not exist.', | |
92 | 'We cannot fetch the video. Please try again later.', | |
93 | 'Sorry', | |
5abc96fc C |
94 | 'This video is not available because the remote instance is not responding.', |
95 | 'This playlist does not exist', | |
4572c3d0 C |
96 | 'We cannot fetch the playlist. Please try again later.', |
97 | 'Playlist: {1}', | |
56674bb9 | 98 | 'By {1}', |
c1961762 | 99 | 'Unavailable video' |
ad3fa0c5 | 100 | ]) |
f0af38e6 | 101 | .forEach(v => { serverKeys[v] = v }) |
7ce44a74 | 102 | |
7ce44a74 C |
103 | // More keys |
104 | Object.assign(serverKeys, { | |
f0af38e6 | 105 | Unknown: 'Unknown' |
7ce44a74 C |
106 | }) |
107 | ||
850c1bf7 C |
108 | // ISO 639 keys |
109 | const languageKeys: any = {} | |
110 | const languages = buildLanguages() | |
f0af38e6 | 111 | Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] }) |
850c1bf7 | 112 | |
3aea8eb2 | 113 | Object.assign(serverKeys, languageKeys) |
850c1bf7 | 114 | |
ef78fdbb | 115 | writeAll().catch(err => { |
7ce44a74 C |
116 | console.error(err) |
117 | process.exit(-1) | |
3aea8eb2 | 118 | }) |
ef78fdbb C |
119 | |
120 | async function writeAll () { | |
f8360396 | 121 | const localePath = join(root(), 'client', 'src', 'locale') |
ef78fdbb C |
122 | |
123 | await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 }) | |
124 | await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 }) | |
125 | ||
126 | for (const key of Object.keys(I18N_LOCALES)) { | |
127 | const playerJsonPath = join(localePath, `player.${key}.json`) | |
128 | const translatedPlayer = require(playerJsonPath) | |
129 | ||
130 | const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer) | |
131 | await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 }) | |
132 | ||
133 | const serverJsonPath = join(localePath, `server.${key}.json`) | |
134 | const translatedServer = require(serverJsonPath) | |
135 | ||
136 | const newTranslatedServer = Object.assign({}, serverKeys, translatedServer) | |
137 | await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 }) | |
138 | } | |
139 | } |