@@ -13,12 +13,21 @@ var gulp = require('gulp'),
1313 replace = require ( 'gulp-replace' ) ,
1414 fs = require ( 'fs' ) ,
1515 smoosher = require ( 'gulp-smoosher' ) ;
16+ size = require ( 'gulp-filesize' ) ;
1617
17- var demoMode = false ;
18- var testMode = false ;
18+ var en_lang = true ;
19+ var fr_lang = false ;
20+ var es_lang = false ;
21+ var de_lang = false ;
22+ var it_lang = false ;
23+ var pl_lang = false ;
24+ var ptbr_lang = false ;
25+ var ru_lang = false ;
26+ var uk_lang = false ;
1927
2028function clean ( ) {
2129 return del ( [ 'dist' ] ) ;
30+
2231}
2332
2433function clean2 ( ) {
@@ -35,7 +44,7 @@ function Copytest() {
3544 gulp . src ( [ 'www/index.html' ] )
3645 . pipe ( removeCode ( { production : false } ) )
3746 . pipe ( removeCode ( { cleanheader : true } ) )
38- . pipe ( gulp . dest ( 'dist' ) ) ,
47+ . pipe ( gulp . dest ( 'dist' ) ) ,
3948 gulp . src ( [ 'www/images/**/*.*' ] )
4049 . pipe ( gulp . dest ( 'dist/images' ) )
4150 )
@@ -46,7 +55,7 @@ function Copy() {
4655 gulp . src ( [ 'www/index.html' ] )
4756 . pipe ( removeCode ( { production : true } ) )
4857 . pipe ( removeCode ( { cleanheader : true } ) )
49- . pipe ( gulp . dest ( 'dist' ) ) ,
58+ . pipe ( gulp . dest ( 'dist' ) ) ,
5059 gulp . src ( [ 'www/images/**/*.*' ] )
5160 . pipe ( gulp . dest ( 'dist/images' ) )
5261 )
@@ -88,6 +97,116 @@ function replaceSVG() {
8897 . pipe ( gulp . dest ( 'dist' ) )
8998}
9099
100+ function clearlang ( ) {
101+ // fetch command line arguments
102+ console . log ( "Enable Language:" ) ;
103+ const arg = ( argList => {
104+
105+ let arg = { } , a , opt , thisOpt , curOpt ;
106+ for ( a = 0 ; a < argList . length ; a ++ ) {
107+
108+ thisOpt = argList [ a ] . trim ( ) ;
109+ opt = thisOpt . replace ( / ^ \- + / , '' ) ;
110+
111+ if ( opt === thisOpt ) {
112+
113+ // argument value
114+ if ( curOpt ) arg [ curOpt ] = opt ;
115+ curOpt = null ;
116+
117+ }
118+ else {
119+
120+ // argument name
121+ curOpt = opt ;
122+ arg [ curOpt ] = true ;
123+
124+ }
125+
126+ }
127+
128+ return arg ;
129+
130+ } ) ( process . argv ) ;
131+
132+ if ( ( typeof arg . lang == 'undefined' ) || ( arg . lang == 'all' ) ) {
133+ en_lang = true ;
134+ fr_lang = true ;
135+ es_lang = true ;
136+ de_lang = true ;
137+ it_lang = true ;
138+ pl_lang = true ;
139+ ptbr_lang = true ;
140+ ru_lang = true ;
141+ uk_lang = true ;
142+ }
143+ if ( arg . lang == 'en' ) {
144+ en_lang = true ;
145+ }
146+ if ( en_lang ) {
147+ console . log ( "en" ) ;
148+ }
149+ if ( arg . lang == 'fr' ) {
150+ fr_lang = true ;
151+ }
152+ if ( fr_lang ) {
153+ console . log ( "fr" ) ;
154+ }
155+ if ( arg . lang == 'es' ) {
156+ es_lang = true ;
157+ }
158+ if ( es_lang ) {
159+ console . log ( "es" ) ;
160+ }
161+ if ( arg . lang == 'de' ) {
162+ de_lang = true ;
163+ }
164+ if ( de_lang ) {
165+ console . log ( "de" ) ;
166+ }
167+ if ( arg . lang == 'it' ) {
168+ it_lang = true ;
169+ }
170+ if ( it_lang ) {
171+ console . log ( "it" ) ;
172+ }
173+ if ( arg . lang == 'pl' ) {
174+ pl_lang = true ;
175+ }
176+ if ( pl_lang ) {
177+ console . log ( "pl" ) ;
178+ }
179+ if ( arg . lang == 'ptbr' ) {
180+ ptbr_lang = true ;
181+ }
182+ if ( ptbr_lang ) {
183+ console . log ( "ptbr" ) ;
184+ }
185+ if ( arg . lang == 'ru' ) {
186+ ru_lang = true ;
187+ }
188+ if ( ru_lang ) {
189+ console . log ( "ru" ) ;
190+ }
191+ if ( arg . lang == 'uk' ) {
192+ uk_lang = true ;
193+ }
194+ if ( uk_lang ) {
195+ console . log ( "uk" ) ;
196+ }
197+ return gulp . src ( 'dist/js/app.js' )
198+ . pipe ( removeCode ( { de_lang_disabled : ! de_lang } ) )
199+ . pipe ( removeCode ( { en_lang_disabled : ! en_lang } ) )
200+ . pipe ( removeCode ( { es_lang_disabled : ! es_lang } ) )
201+ . pipe ( removeCode ( { fr_lang_disabled : ! fr_lang } ) )
202+ . pipe ( removeCode ( { it_lang_disabled : ! it_lang } ) )
203+ . pipe ( removeCode ( { pl_lang_disabled : ! pl_lang } ) )
204+ . pipe ( removeCode ( { ptbr_lang_disabled : ! ptbr_lang } ) )
205+ . pipe ( removeCode ( { ru_lang_disabled : ! ru_lang } ) )
206+ . pipe ( removeCode ( { uk_lang_disabled : ! uk_lang } ) )
207+ . pipe ( gulp . dest ( './dist/js/' ) )
208+ }
209+
91210function minifyApp ( ) {
92211 return merge (
93212 gulp . src ( [ 'dist/js/app.js' ] )
@@ -125,10 +244,12 @@ function smoosh() {
125244
126245function compress ( ) {
127246 return gulp . src ( 'dist/index.html' )
128- . pipe ( gzip ( ) )
129- . pipe ( gulp . dest ( '.' ) ) ;
247+ . pipe ( gzip ( { gzipOptions : { level : 9 } } ) )
248+ . pipe ( gulp . dest ( '.' ) )
249+ . pipe ( size ( ) ) ;
130250}
131251
252+
132253gulp . task ( clean ) ;
133254gulp . task ( lint ) ;
134255gulp . task ( Copy ) ;
@@ -139,10 +260,11 @@ gulp.task(concatApptest);
139260gulp . task ( minifyApp ) ;
140261gulp . task ( smoosh ) ;
141262gulp . task ( clean2 ) ;
263+ gulp . task ( clearlang )
142264
143265var defaultSeries = gulp . series ( clean , lint , Copy , concatApp , minifyApp , includehtml , includehtml , smoosh ) ;
144266//var packageSeries = gulp.series(clean, lint, Copy, concatApp, minifyApp, smoosh, compress);
145- var packageSeries = gulp . series ( clean , lint , Copy , concatApp , includehtml , includehtml , replaceSVG , minifyApp , smoosh , compress , clean2 ) ;
267+ var packageSeries = gulp . series ( clean , lint , Copy , concatApp , includehtml , includehtml , replaceSVG , clearlang , minifyApp , smoosh , compress , clean2 ) ;
146268var package2Series = gulp . series ( clean , lint , Copy , concatApp , includehtml , includehtml , replaceSVG , smoosh ) ;
147269var package2testSeries = gulp . series ( clean , lint , Copytest , concatApptest , includehtml , includehtml , replaceSVG , smoosh ) ;
148270
0 commit comments