From fefe3f0c048d9e5315a4350e96ec7ecf95259dfb Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Fri, 1 May 2020 17:24:49 +0200
Subject: [PATCH] [enh] Add i18n JSON check (jsonlint) [fix] Fix i18n ES json
 format

---
 gulpfile.js                | 15 ++++++++----
 package.json               |  1 +
 www/i18n/locale-es-ES.json |  2 +-
 yarn.lock                  | 47 +++++++++++++++++++++++++++++++++++++-
 4 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index bd2307c8..31d77dad 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -33,7 +33,8 @@ const gulp = require('gulp'),
   colors = require('ansi-colors'),
   argv = require('yargs').argv,
   sriHash = require('gulp-sri-hash'),
-  sort = require('gulp-sort');
+  sort = require('gulp-sort'),
+  jsonlint = require("@prantlf/gulp-jsonlint");
 
 const paths = {
   license_md: ['./www/license/*.md'],
@@ -160,6 +161,8 @@ function appNgTranslate() {
   log(colors.green('Building App translation file...'));
 
   return gulp.src('www/i18n/locale-*.json')
+    .pipe(jsonlint())
+    .pipe(jsonlint.reporter())
     .pipe(sort())
     .pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
     .pipe(gulp.dest('www/dist/dist_js/app'));
@@ -221,6 +224,8 @@ function pluginNgTranslate() {
   log(colors.green('Building Plugins translation file...'));
 
   return gulp.src(paths.ng_translate_plugin)
+    .pipe(jsonlint())
+    .pipe(jsonlint.reporter())
     .pipe(sort())
     .pipe(ngTranslate({standalone:true, module: 'cesium.plugins.translations'}))
     .pipe(gulp.dest('www/dist/dist_js/plugins'));
@@ -324,6 +329,8 @@ function webCopyFiles() {
 
     // Copy i18n
     gulp.src('./www/i18n/locale-*.json')
+      .pipe(jsonlint())
+      .pipe(jsonlint.reporter())
       .pipe(sort())
       .pipe(ngTranslate({standalone:true, module: 'cesium.translations'}))
       .pipe(gulp.dest(tmpPath + '/js')),
@@ -336,10 +343,6 @@ function webCopyFiles() {
     gulp.src('./www/manifest.json')
       .pipe(gulp.dest(tmpPath)),
 
-    // Copy feed*.json
-    //gulp.src('./www/feed*.json')
-    //  .pipe(gulp.dest(tmpPath)),
-
     // Copy lib (JS, CSS and fonts)
     gulp.src(['./www/lib/**/*.js', './www/lib/**/*.css', './www/lib/**/fonts/**/*.*'])
       .pipe(gulp.dest(tmpPath + '/lib')),
@@ -400,6 +403,8 @@ function webPluginCopyFiles() {
 
     // Transform i18n into JS
     gulp.src(paths.ng_translate_plugin)
+      .pipe(jsonlint())
+      .pipe(jsonlint.reporter())
       .pipe(sort())
       .pipe(ngTranslate({standalone:true, module: 'cesium.plugins.translations'}))
       .pipe(gulp.dest(tmpPath + '/dist/dist_js/plugins')),
diff --git a/package.json b/package.json
index 985582f1..e94665a4 100644
--- a/package.json
+++ b/package.json
@@ -109,6 +109,7 @@
   "devDependencies": {
     "@ionic/cli": "^6.7.0",
     "@ionic/v1-toolkit": "^3.2.0",
+    "@prantlf/gulp-jsonlint": "^2.4.0",
     "cordova-uglify": "^0.3.4",
     "del": "^5.1.0",
     "delete-empty": "^0.1.3",
diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json
index 8d1f453e..6a366b69 100644
--- a/www/i18n/locale-es-ES.json
+++ b/www/i18n/locale-es-ES.json
@@ -1004,4 +1004,4 @@
       "END_NOT_LOGIN": "¡La visita guiada ha <b>terminado</b>!<br/><br/>Si quiere utilizar la moneda {{currency|capitalize}}, tiene que hacer un clic en <b>{{'LOGIN.CREATE_ACCOUNT'|translate}}</b> más abajo."
     }
   }
-},
+}
diff --git a/yarn.lock b/yarn.lock
index 8fc9aba8..19ab53a2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -448,6 +448,26 @@
     "@nodelib/fs.scandir" "2.1.3"
     fastq "^1.6.0"
 
+"@prantlf/gulp-jsonlint@^2.4.0":
+  version "2.4.0"
+  resolved "https://registry.yarnpkg.com/@prantlf/gulp-jsonlint/-/gulp-jsonlint-2.4.0.tgz#282d468c9b067f98202809274619e4b5d22fe30e"
+  integrity sha512-13L1ZZShhETd7m5ZIoG4yBNqlOrcf6hNHMU5XhfWs45pSD259Kw/ycwEi23HcthWZfcyLpkxgvciBFKze/bz1w==
+  dependencies:
+    "@prantlf/jsonlint" "10.2.0"
+    ansi-colors "4.1.1"
+    fancy-log "1.3.3"
+    map-stream "0.0.7"
+    plugin-error "1.0.1"
+    through2 "3.0.1"
+
+"@prantlf/jsonlint@10.2.0":
+  version "10.2.0"
+  resolved "https://registry.yarnpkg.com/@prantlf/jsonlint/-/jsonlint-10.2.0.tgz#0716001895cc5f0407820ffe9887de5e13e6fa47"
+  integrity sha512-KMFfds0peWLLfCu3bhClTiEN0tdj/Z86QJvn1awKHws6r+Sx6T3a44Eadz6OvqN6ZpsRkqaRpZxqddvvDAdDZQ==
+  dependencies:
+    ajv "6.10.2"
+    commander "4.0.1"
+
 "@types/color-name@^1.1.1":
   version "1.1.1"
   resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
@@ -585,6 +605,16 @@ aggregate-error@^3.0.0:
     clean-stack "^2.0.0"
     indent-string "^4.0.0"
 
+ajv@6.10.2:
+  version "6.10.2"
+  resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52"
+  integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==
+  dependencies:
+    fast-deep-equal "^2.0.1"
+    fast-json-stable-stringify "^2.0.0"
+    json-schema-traverse "^0.4.1"
+    uri-js "^4.2.2"
+
 ajv@^6.5.5:
   version "6.12.0"
   resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7"
@@ -641,6 +671,11 @@ ansi-align@^2.0.0:
   dependencies:
     string-width "^2.0.0"
 
+ansi-colors@4.1.1:
+  version "4.1.1"
+  resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
+  integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
+
 ansi-colors@^1.0.1:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-1.1.0.tgz#6374b4dd5d4718ff3ce27a671a3b1cad077132a9"
@@ -2061,6 +2096,11 @@ commander@2.5.x:
   resolved "https://registry.yarnpkg.com/commander/-/commander-2.5.1.tgz#23c61f6e47be143cc02e7ad4bb1c47f5cd5a2883"
   integrity sha1-I8Yfbke+FDzALnrUuxxH9c1aKIM=
 
+commander@4.0.1:
+  version "4.0.1"
+  resolved "https://registry.yarnpkg.com/commander/-/commander-4.0.1.tgz#b67622721785993182e807f4883633e6401ba53c"
+  integrity sha512-IPF4ouhCP+qdlcmCedhxX4xiGBPyigb8v5NeUp+0LyhwLgxMqyp3S0vl7TAPfS/hiP7FC3caI/PB9lTmP8r1NA==
+
 commander@^2.20.0, commander@^2.9.0:
   version "2.20.3"
   resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@@ -3781,7 +3821,7 @@ falafel@^2.0.0:
     isarray "^2.0.1"
     object-keys "^1.0.6"
 
-fancy-log@^1.1.0, fancy-log@^1.3.2:
+fancy-log@1.3.3, fancy-log@^1.1.0, fancy-log@^1.3.2:
   version "1.3.3"
   resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.3.tgz#dbc19154f558690150a23953a0adbd035be45fc7"
   integrity sha512-k9oEhlyc0FrVh25qYuSELjr8oxsCoc4/LEZfg2iJJrfEk/tZL9bCoJE47gqAvI2m/AUjluCS4+3I0eTx8n3AEw==
@@ -3791,6 +3831,11 @@ fancy-log@^1.1.0, fancy-log@^1.3.2:
     parse-node-version "^1.0.0"
     time-stamp "^1.0.0"
 
+fast-deep-equal@^2.0.1:
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
+  integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=
+
 fast-deep-equal@^3.1.1:
   version "3.1.1"
   resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4"
-- 
GitLab