diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-14 09:32:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-08-14 09:32:20 +0200 |
commit | ef78fdbb2ef51033822e174cfe38b3f0d664df56 (patch) | |
tree | 7ccc72893bc6bac7c2e9ea98299e5502c88b6533 /scripts/i18n/create-custom-files.ts | |
parent | 6f0db095f898ce0c0f20b3d117f300ed5a35824c (diff) | |
download | PeerTube-ef78fdbb2ef51033822e174cfe38b3f0d664df56.tar.gz PeerTube-ef78fdbb2ef51033822e174cfe38b3f0d664df56.tar.zst PeerTube-ef78fdbb2ef51033822e174cfe38b3f0d664df56.zip |
Update player and server translations
Diffstat (limited to 'scripts/i18n/create-custom-files.ts')
-rwxr-xr-x | scripts/i18n/create-custom-files.ts | 31 |
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 @@ | |||
1 | import { registerTSPaths } from '../../server/helpers/register-ts-paths' | ||
2 | import { writeJSON } from 'fs-extra' | 1 | import { writeJSON } from 'fs-extra' |
2 | import { values } from 'lodash' | ||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { registerTSPaths } from '../../server/helpers/register-ts-paths' | ||
4 | import { | 5 | import { |
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' |
14 | import { values } from 'lodash' | 15 | import { I18N_LOCALES } from '../../shared/core-utils/i18n' |
15 | 16 | ||
16 | registerTSPaths() | 17 | registerTSPaths() |
17 | 18 | ||
@@ -70,10 +71,28 @@ Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] | |||
70 | 71 | ||
71 | Object.assign(serverKeys, languageKeys) | 72 | Object.assign(serverKeys, languageKeys) |
72 | 73 | ||
73 | Promise.all([ | 74 | writeAll().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 | |||
79 | async 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 | } | ||