aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-11-07 15:33:23 +0100
committerChocobozzz <me@florianbigard.com>2019-11-13 10:04:16 +0100
commit350131cbaf99bd1cbb2d0911093aa94d105de709 (patch)
tree9b90dc4d3ca327aadb8e45f7e18c4648d9412a56
parent81ad5366f745a0c0459016d3af5d18d1dd4501c0 (diff)
downloadPeerTube-350131cbaf99bd1cbb2d0911093aa94d105de709.tar.gz
PeerTube-350131cbaf99bd1cbb2d0911093aa94d105de709.tar.zst
PeerTube-350131cbaf99bd1cbb2d0911093aa94d105de709.zip
Make build works
-rw-r--r--client/src/app/app.module.ts4
-rw-r--r--client/src/main.ts2
-rwxr-xr-xscripts/build/client.sh28
-rwxr-xr-xscripts/watch/server.sh2
-rw-r--r--server/controllers/client.ts2
-rw-r--r--shared/models/i18n/i18n.ts4
6 files changed, 20 insertions, 22 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index a3ea33ca9..38b7328e2 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -76,7 +76,7 @@ export function metaFactory (serverService: ServerService): MetaLoader {
76 // On dev mode, test localization 76 // On dev mode, test localization
77 if (isOnDevLocale()) { 77 if (isOnDevLocale()) {
78 locale = buildFileLocale(getDevLocale()) 78 locale = buildFileLocale(getDevLocale())
79 return require(`raw-loader!../locale/target/angular_${locale}.xml`) 79 return require(`raw-loader!../locale/angular.${locale}.xlf`)
80 } 80 }
81 81
82 // Default locale, nothing to translate 82 // Default locale, nothing to translate
@@ -84,7 +84,7 @@ export function metaFactory (serverService: ServerService): MetaLoader {
84 if (isDefaultLocale(completeLocale)) return '' 84 if (isDefaultLocale(completeLocale)) return ''
85 85
86 const fileLocale = buildFileLocale(locale) 86 const fileLocale = buildFileLocale(locale)
87 return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`) 87 return require(`raw-loader!../locale/angular.${fileLocale}.xlf`)
88 }, 88 },
89 deps: [ LOCALE_ID ] 89 deps: [ LOCALE_ID ]
90 }, 90 },
diff --git a/client/src/main.ts b/client/src/main.ts
index 86fdabba5..2b65072ad 100644
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -16,7 +16,7 @@ if (environment.production) {
16// Template translation, should be in the bootstrap step 16// Template translation, should be in the bootstrap step
17if (isOnDevLocale()) { 17if (isOnDevLocale()) {
18 const locale = buildFileLocale(getDevLocale()) 18 const locale = buildFileLocale(getDevLocale())
19 const translations = require(`raw-loader!./locale/target/angular_${locale}.xml`) 19 const translations = require(`raw-loader!./locale/angular.${locale}.xlf`)
20 20
21 providers = [ 21 providers = [
22 { provide: TRANSLATIONS, useValue: translations }, 22 { provide: TRANSLATIONS, useValue: translations },
diff --git a/scripts/build/client.sh b/scripts/build/client.sh
index 9dfa6c618..2518702cf 100755
--- a/scripts/build/client.sh
+++ b/scripts/build/client.sh
@@ -3,23 +3,23 @@
3set -eu 3set -eu
4 4
5pre_build_hook () { 5pre_build_hook () {
6 mkdir "./src/locale/pending_target/" > /dev/null || true 6 mkdir "./src/pending_locale" > /dev/null || true
7 mv ./src/locale/target/angular_*.xml "./src/locale/pending_target" 7 mv ./src/locale/angular.*.xlf "./src/pending_locale"
8 8
9 if [ ! -z ${1+x} ]; then 9 if [ ! -z ${1+x} ]; then
10 mv "./src/locale/pending_target/angular_$1.xml" "./src/locale/target" 10 mv "./src/pending_locale/angular.$1.xlf" "./src/locale"
11 fi 11 fi
12} 12}
13 13
14post_build_hook () { 14post_build_hook () {
15 mv ./src/locale/pending_target/* "./src/locale/target/" 15 mv ./src/pending_locale/* "./src/locale"
16 rmdir "./src/locale/pending_target/" 16 rmdir "./src/pending_locale/"
17} 17}
18 18
19# Previous build failed 19# Previous build failed
20if [ ! -f client/src/locale/target/angular_fr_FR.xml ]; then 20if [ ! -f "client/src/locale/angular.fr-FR.xlf" ]; then
21 git checkout -- client/src/locale/target/ 21 git checkout -- client/src/locale/
22 rm -r client/src/locale/pending_target/ 22 rm -r client/src/pending_locale
23fi 23fi
24 24
25cd client 25cd client
@@ -28,7 +28,7 @@ rm -rf ./dist ./compiled
28 28
29pre_build_hook 29pre_build_hook
30 30
31defaultLanguage="en_US" 31defaultLanguage="en-US"
32npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json 32npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json
33mv "./dist/$defaultLanguage/assets" "./dist" 33mv "./dist/$defaultLanguage/assets" "./dist"
34mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest" 34mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
@@ -38,12 +38,12 @@ post_build_hook
38# Don't build other languages if --light arg is provided 38# Don't build other languages if --light arg is provided
39if [ -z ${1+x} ] || [ "$1" != "--light" ]; then 39if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
40 if [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then 40 if [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then
41 languages=("fr_FR") 41 languages=("fr-FR")
42 else 42 else
43 # Supported languages 43 # Supported languages
44 languages=( 44 languages=(
45 "fi_FI" "nl_NL" "gd" "el_GR" "es_ES" "oc" "pt_BR" "pt_PT" "sv_SE" "pl_PL" "ru_RU" "zh_Hans_CN" "zh_Hant_TW" 45 "fi-FI" "nl-NL" "gd" "el-GR" "es-ES" "oc" "pt-BR" "pt-PT" "sv-SE" "pl-PL" "ru-RU" "zh-Hans-CN" "zh-Hant-TW"
46 "fr_FR" "ja_JP" "eu_ES" "ca_ES" "cs_CZ" "eo" "de_DE" "it_IT" 46 "fr-FR" "ja-JP" "eu-ES" "ca-ES" "cs-CZ" "eo" "de-DE" "it-IT"
47 ) 47 )
48 fi 48 fi
49 49
@@ -51,7 +51,7 @@ if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
51 # TODO: remove when the project will use runtime translations 51 # TODO: remove when the project will use runtime translations
52 pre_build_hook "$lang" 52 pre_build_hook "$lang"
53 53
54 npm run ng build -- --prod --i18n-file "./src/locale/target/angular_$lang.xml" --i18n-format xlf --i18n-locale "$lang" \ 54 npm run ng build -- --prod --i18n-file "./src/locale/angular.$lang.xlf" --i18n-format xlf --i18n-locale "$lang" \
55 --output-path "dist/$lang/" --deploy-url "/client/$lang/" 55 --output-path "dist/$lang/" --deploy-url "/client/$lang/"
56 56
57 # Do not duplicate assets 57 # Do not duplicate assets
@@ -65,4 +65,4 @@ fi
65NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json" 65NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json"
66 66
67# Copy runtime locales 67# Copy runtime locales
68cp -r "./src/locale/target" "./dist/locale" 68cp -r "./src/locale" "./dist/locale"
diff --git a/scripts/watch/server.sh b/scripts/watch/server.sh
index 635bebf8e..8d8470954 100755
--- a/scripts/watch/server.sh
+++ b/scripts/watch/server.sh
@@ -5,7 +5,7 @@ set -eu
5# Copy locales 5# Copy locales
6mkdir -p "./client/dist" 6mkdir -p "./client/dist"
7rm -rf "./client/dist/locale" 7rm -rf "./client/dist/locale"
8cp -r "./client/src/locale/target" "./client/dist/locale" 8cp -r "./client/src/locale" "./client/dist/locale"
9 9
10rm -rf "./dist" 10rm -rf "./dist"
11 11
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 2af00e475..f9bbedc92 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -75,7 +75,7 @@ async function serveServerTranslations (req: express.Request, res: express.Respo
75 const completeLocale = getCompleteLocale(locale) 75 const completeLocale = getCompleteLocale(locale)
76 const completeFileLocale = buildFileLocale(completeLocale) 76 const completeFileLocale = buildFileLocale(completeLocale)
77 77
78 const path = join(__dirname, `../../../client/dist/locale/${file}_${completeFileLocale}.json`) 78 const path = join(__dirname, `../../../client/dist/locale/${file}.${completeFileLocale}.json`)
79 return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER }) 79 return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER })
80 } 80 }
81 81
diff --git a/shared/models/i18n/i18n.ts b/shared/models/i18n/i18n.ts
index 03a5d858a..032944281 100644
--- a/shared/models/i18n/i18n.ts
+++ b/shared/models/i18n/i18n.ts
@@ -83,7 +83,5 @@ export function getShortLocale (locale: string) {
83} 83}
84 84
85export function buildFileLocale (locale: string) { 85export function buildFileLocale (locale: string) {
86 const completeLocale = getCompleteLocale(locale) 86 return getCompleteLocale(locale)
87
88 return completeLocale.replace(/-/g, '_')
89} 87}