1 import { registerTSPaths } from '../../server/helpers/register-ts-paths'
4 import * as jsToXliff12 from 'xliff/jsToXliff12'
5 import { writeFile } from 'fs-extra'
6 import { join } from 'path'
11 VIDEO_LICENCES, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES,
14 } from '../../server/initializers/constants'
15 import { values } from 'lodash'
17 type TranslationType = {
19 data: { [id: string]: string }
22 const videojs = require(join(__dirname, '../../../client/src/locale/source/videojs_en_US.json'))
27 'Subtitles/CC': 'Subtitles/CC',
30 'Go to the video page': 'Go to the video page',
31 'Settings': 'Settings',
32 'Uses P2P, others may know you are watching this video.': 'Uses P2P, others may know you are watching this video.',
33 'Copy the video URL': 'Copy the video URL',
34 'Copy the video URL at the current time': 'Copy the video URL at the current time',
35 'Copy embed code': 'Copy embed code',
36 'Copy magnet URI': 'Copy magnet URI',
37 'Total downloaded: ': 'Total downloaded: ',
38 'Total uploaded: ': 'Total uploaded: '
40 const playerTranslations = {
41 target: join(__dirname, '../../../client/src/locale/source/player_en_US.xml'),
42 data: Object.assign({}, videojs, playerKeys)
46 const serverKeys: any = {}
47 values(VIDEO_CATEGORIES)
48 .concat(values(VIDEO_LICENCES))
49 .concat(values(VIDEO_PRIVACIES))
50 .concat(values(VIDEO_STATES))
51 .concat(values(VIDEO_IMPORT_STATES))
52 .concat(values(VIDEO_PLAYLIST_PRIVACIES))
53 .concat(values(VIDEO_PLAYLIST_TYPES))
55 'This video does not exist.',
56 'We cannot fetch the video. Please try again later.',
58 'This video is not available because the remote instance is not responding.'
60 .forEach(v => serverKeys[v] = v)
63 Object.assign(serverKeys, {
68 const serverTranslations = {
69 target: join(__dirname, '../../../client/src/locale/source/server_en_US.xml'),
74 const languageKeys: any = {}
75 const languages = buildLanguages()
76 Object.keys(languages).forEach(k => languageKeys[languages[k]] = languages[k])
78 const iso639Translations = {
79 target: join(__dirname, '../../../client/src/locale/source/iso639_en_US.xml'),
83 saveToXliffFile(playerTranslations, err => {
84 if (err) return handleError(err)
86 saveToXliffFile(serverTranslations, err => {
87 if (err) return handleError(err)
89 saveToXliffFile(iso639Translations, err => {
90 if (err) return handleError(err)
97 // Then, the server strings
99 function saveToXliffFile (jsonTranslations: TranslationType, cb: Function) {
105 Object.keys(jsonTranslations.data).forEach(k => obj.resources.namespace1[ k ] = { source: jsonTranslations.data[ k ] })
107 jsToXliff12(obj, (err, res) => {
108 if (err) return cb(err)
110 writeFile(jsonTranslations.target, res, err => {
111 if (err) return cb(err)
118 function handleError (err: any) {