PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.2
JetFormBuilder — Dynamic Blocks Form Builder v3.1.2
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / gulpfile.js
jetformbuilder / assets Last commit date
.config 2 years ago .helpers 2 years ago blocks-src 2 years ago css 2 years ago img 2 years ago js 2 years ago lib 2 years ago schemas 2 years ago scss 2 years ago src 2 years ago .babelrc 2 years ago gulpfile.js 2 years ago package.json 2 years ago
gulpfile.js
80 lines
1 let gulp = require( 'gulp' ),
2 po2json = require( 'po2json' ),
3 path = require( 'path' ),
4 fs = require( 'fs' ),
5 Jed = require( 'jed' ),
6 Write = require( 'write' );
7
8 const langPath = ( file = '' ) => path.join( __dirname, '../languages', file );
9
10 function getPOFiles( path ) {
11 return new Promise( ( resolve, reject ) => {
12 fs.readdir( path, function( err, files ) {
13 //handling error
14 if ( err ) {
15 return console.log( 'Unable to scan directory: ' + err );
16 }
17 resolve( files
18 .filter( file => /^.*\.po$/.test( file ) )
19 .map( file => langPath( '/' + file ) ),
20 );
21 } );
22 } );
23 }
24
25 function getArgv( name, ifNotExist = false ) {
26 const argIndex = process.argv.indexOf( name );
27 if ( -1 === argIndex ) {
28 return ifNotExist;
29 }
30
31 return process.argv[ argIndex + 1 ] || ifNotExist;
32 }
33
34 const taskJFBi18n = async () => {
35 const handlers = [ 'jfb-settings', 'jfb-addons', 'jet-form-builder-editor-package' ];
36
37 const parseI18nJson = ( err, jsonData, handler, PO_file ) => {
38
39 let i18n = new Jed( jsonData )
40 let JSON_file = PO_file.replace( '.po', `-${ handler }.json` )
41
42 let locale_data = i18n.options.locale_data;
43
44 for ( const message in locale_data.messages ) {
45 if ( ! message || ! Array.isArray( locale_data.messages[ message ] ) ) {
46 continue;
47 }
48
49 locale_data.messages[ message ] = locale_data.messages[ message ].filter( translate => {
50 return ( "" === translate || translate );
51 } )
52 }
53
54 Write.sync( JSON_file, JSON.stringify( { locale_data }, null, 4 ), { newline: true } )
55 };
56
57 function writeJSONby( main_PO_file ) {
58 handlers.forEach( handler => {
59 po2json.parseFile(
60 main_PO_file,
61 { format: 'jed' },
62 ( err, jsonData ) => parseI18nJson( err, jsonData, handler, main_PO_file ),
63 );
64 } );
65 }
66
67 const files = await getPOFiles( langPath() );
68
69 console.log( files );
70
71 files.forEach( writeJSONby );
72 }
73
74 gulp.task( 'jfb-i18n', taskJFBi18n );
75
76 gulp.task( 'jfb-i18n-watch', async () => {
77 gulp.watch( '../languages/*.po' , taskJFBi18n );
78 } );
79
80