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