Browse Source

Make build works

Chocobozzz 1 month ago
parent
commit
350131cbaf
No account linked to committer's email address

+ 2
- 2
client/src/app/app.module.ts View File

@@ -76,7 +76,7 @@ export function metaFactory (serverService: ServerService): MetaLoader {
76 76
         // On dev mode, test localization
77 77
         if (isOnDevLocale()) {
78 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 82
         // Default locale, nothing to translate
@@ -84,7 +84,7 @@ export function metaFactory (serverService: ServerService): MetaLoader {
84 84
         if (isDefaultLocale(completeLocale)) return ''
85 85
 
86 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 89
       deps: [ LOCALE_ID ]
90 90
     },

+ 1
- 1
client/src/main.ts View File

@@ -16,7 +16,7 @@ if (environment.production) {
16 16
 // Template translation, should be in the bootstrap step
17 17
 if (isOnDevLocale()) {
18 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 21
   providers = [
22 22
     { provide: TRANSLATIONS, useValue: translations },

+ 14
- 14
scripts/build/client.sh View File

@@ -3,23 +3,23 @@
3 3
 set -eu
4 4
 
5 5
 pre_build_hook () {
6
-  mkdir "./src/locale/pending_target/" > /dev/null || true
7
-  mv ./src/locale/target/angular_*.xml "./src/locale/pending_target"
6
+  mkdir "./src/pending_locale" > /dev/null || true
7
+  mv ./src/locale/angular.*.xlf "./src/pending_locale"
8 8
 
9 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 11
   fi
12 12
 }
13 13
 
14 14
 post_build_hook () {
15
-  mv ./src/locale/pending_target/* "./src/locale/target/"
16
-  rmdir "./src/locale/pending_target/"
15
+  mv ./src/pending_locale/* "./src/locale"
16
+  rmdir "./src/pending_locale/"
17 17
 }
18 18
 
19 19
 # Previous build failed
20
-if [ ! -f client/src/locale/target/angular_fr_FR.xml ]; then
21
-    git checkout -- client/src/locale/target/
22
-    rm -r client/src/locale/pending_target/
20
+if [ ! -f "client/src/locale/angular.fr-FR.xlf" ]; then
21
+    git checkout -- client/src/locale/
22
+    rm -r client/src/pending_locale
23 23
 fi
24 24
 
25 25
 cd client
@@ -28,7 +28,7 @@ rm -rf ./dist ./compiled
28 28
 
29 29
 pre_build_hook
30 30
 
31
-defaultLanguage="en_US"
31
+defaultLanguage="en-US"
32 32
 npm run ng build -- --output-path "dist/$defaultLanguage/" --deploy-url "/client/$defaultLanguage/" --prod --stats-json
33 33
 mv "./dist/$defaultLanguage/assets" "./dist"
34 34
 mv "./dist/$defaultLanguage/manifest.webmanifest" "./dist/manifest.webmanifest"
@@ -38,12 +38,12 @@ post_build_hook
38 38
 # Don't build other languages if --light arg is provided
39 39
 if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
40 40
     if [ ! -z ${1+x} ] && [ "$1" == "--light-fr" ]; then
41
-        languages=("fr_FR")
41
+        languages=("fr-FR")
42 42
     else
43 43
         # Supported languages
44 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"
46
-            "fr_FR" "ja_JP" "eu_ES" "ca_ES" "cs_CZ" "eo" "de_DE" "it_IT"
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"
47 47
         )
48 48
     fi
49 49
 
@@ -51,7 +51,7 @@ if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
51 51
         # TODO: remove when the project will use runtime translations
52 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 55
             --output-path "dist/$lang/" --deploy-url "/client/$lang/"
56 56
 
57 57
         # Do not duplicate assets
@@ -65,4 +65,4 @@ fi
65 65
 NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json"
66 66
 
67 67
 # Copy runtime locales
68
-cp -r "./src/locale/target" "./dist/locale"
68
+cp -r "./src/locale" "./dist/locale"

+ 1
- 1
scripts/watch/server.sh View File

@@ -5,7 +5,7 @@ set -eu
5 5
 # Copy locales
6 6
 mkdir -p "./client/dist"
7 7
 rm -rf "./client/dist/locale"
8
-cp -r "./client/src/locale/target" "./client/dist/locale"
8
+cp -r "./client/src/locale" "./client/dist/locale"
9 9
 
10 10
 rm -rf "./dist"
11 11
 

+ 1
- 1
server/controllers/client.ts View File

@@ -75,7 +75,7 @@ async function serveServerTranslations (req: express.Request, res: express.Respo
75 75
     const completeLocale = getCompleteLocale(locale)
76 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 79
     return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER })
80 80
   }
81 81
 

+ 1
- 3
shared/models/i18n/i18n.ts View File

@@ -83,7 +83,5 @@ export function getShortLocale (locale: string) {
83 83
 }
84 84
 
85 85
 export function buildFileLocale (locale: string) {
86
-  const completeLocale = getCompleteLocale(locale)
87
-
88
-  return completeLocale.replace(/-/g, '_')
86
+  return getCompleteLocale(locale)
89 87
 }

Loading…
Cancel
Save