aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/i18n
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/i18n')
-rwxr-xr-xscripts/i18n/create-custom-files.ts31
1 files changed, 25 insertions, 6 deletions
diff --git a/scripts/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts
index 78a51d1e6..7a33ab624 100755
--- a/scripts/i18n/create-custom-files.ts
+++ b/scripts/i18n/create-custom-files.ts
@@ -1,6 +1,7 @@
1import { registerTSPaths } from '../../server/helpers/register-ts-paths'
2import { writeJSON } from 'fs-extra' 1import { writeJSON } from 'fs-extra'
2import { values } from 'lodash'
3import { join } from 'path' 3import { join } from 'path'
4import { registerTSPaths } from '../../server/helpers/register-ts-paths'
4import { 5import {
5 buildLanguages, 6 buildLanguages,
6 VIDEO_CATEGORIES, 7 VIDEO_CATEGORIES,
@@ -11,7 +12,7 @@ import {
11 VIDEO_PRIVACIES, 12 VIDEO_PRIVACIES,
12 VIDEO_STATES 13 VIDEO_STATES
13} from '../../server/initializers/constants' 14} from '../../server/initializers/constants'
14import { values } from 'lodash' 15import { I18N_LOCALES } from '../../shared/core-utils/i18n'
15 16
16registerTSPaths() 17registerTSPaths()
17 18
@@ -70,10 +71,28 @@ Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k]
70 71
71Object.assign(serverKeys, languageKeys) 72Object.assign(serverKeys, languageKeys)
72 73
73Promise.all([ 74writeAll().catch(err => {
74 writeJSON(join(__dirname, '../../../client/src/locale/player.en-US.json'), playerKeys),
75 writeJSON(join(__dirname, '../../../client/src/locale/server.en-US.json'), serverKeys)
76]).catch(err => {
77 console.error(err) 75 console.error(err)
78 process.exit(-1) 76 process.exit(-1)
79}) 77})
78
79async function writeAll () {
80 const localePath = join(__dirname, '../../../client/src/locale')
81
82 await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
83 await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
84
85 for (const key of Object.keys(I18N_LOCALES)) {
86 const playerJsonPath = join(localePath, `player.${key}.json`)
87 const translatedPlayer = require(playerJsonPath)
88
89 const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
90 await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
91
92 const serverJsonPath = join(localePath, `server.${key}.json`)
93 const translatedServer = require(serverJsonPath)
94
95 const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
96 await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
97 }
98}