fooplugins /
foogallery
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | var gulp = require('gulp'); |
||
| 2 | var path = require('path'); |
||
| 3 | var filesystem = require('fs'); |
||
| 4 | var wpPot = require('gulp-wp-pot'); |
||
| 5 | var gettext = require('gulp-gettext'); |
||
| 6 | var sort = require('gulp-sort'); |
||
| 7 | var pofill = require('gulp-pofill'); |
||
| 8 | var rename = require('gulp-rename'); |
||
| 9 | var clean = require('gulp-clean'); |
||
| 10 | |||
| 11 | var languagesFolder = './languages/'; |
||
| 12 | |||
| 13 | var options = require('./transifex-config.json'); |
||
| 14 | |||
| 15 | function getFolders(dir) { |
||
| 16 | return filesystem.readdirSync(dir) |
||
| 17 | .filter(function (file) { |
||
| 18 | return filesystem.statSync(path.join(dir, file)).isDirectory(); |
||
| 19 | }); |
||
| 20 | } |
||
| 21 | |||
| 22 | var transifex = require('gulp-transifex').createClient(options); |
||
| 23 | |||
| 24 | // Create POT out of i18n.php. |
||
| 25 | gulp.task('prepare-source', function () { |
||
| 26 | gulp.src('**/*.php') |
||
| 27 | .pipe(sort()) |
||
| 28 | .pipe(wpPot({ |
||
| 29 | destFile : 'freemius.pot', |
||
| 30 | package : 'freemius', |
||
| 31 | bugReport : 'https://github.com/Freemius/wordpress-sdk/issues', |
||
| 32 | lastTranslator : 'Vova Feldman <[email protected]>', |
||
| 33 | team : 'Freemius Team <[email protected]>', |
||
| 34 | /*gettextMethods: { |
||
| 35 | instances: ['this', '_fs'], |
||
| 36 | methods: [ |
||
| 37 | 'get_text_inline' |
||
| 38 | ] |
||
| 39 | },*/ |
||
| 40 | gettextFunctions: [ |
||
| 41 | {name: 'get_text_inline'}, |
||
| 42 | |||
| 43 | {name: 'fs_text_inline'}, |
||
| 44 | {name: 'fs_echo_inline'}, |
||
| 45 | {name: 'fs_esc_js_inline'}, |
||
| 46 | {name: 'fs_esc_attr_inline'}, |
||
| 47 | {name: 'fs_esc_attr_echo_inline'}, |
||
| 48 | {name: 'fs_esc_html_inline'}, |
||
| 49 | {name: 'fs_esc_html_echo_inline'}, |
||
| 50 | |||
| 51 | {name: 'get_text_x_inline', context: 2}, |
||
| 52 | {name: 'fs_text_x_inline', context: 2}, |
||
| 53 | {name: 'fs_echo_x_inline', context: 2}, |
||
| 54 | {name: 'fs_esc_attr_x_inline', context: 2}, |
||
| 55 | {name: 'fs_esc_js_x_inline', context: 2}, |
||
| 56 | {name: 'fs_esc_js_echo_x_inline', context: 2}, |
||
| 57 | {name: 'fs_esc_html_x_inline', context: 2}, |
||
| 58 | {name: 'fs_esc_html_echo_x_inline', context: 2} |
||
| 59 | /*, |
||
| 60 | |||
| 61 | |||
| 62 | {name: '_fs_text'}, |
||
| 63 | {name: '_fs_x', context: 2}, |
||
| 64 | {name: '_fs_echo'}, |
||
| 65 | {name: '_fs_esc_attr'}, |
||
| 66 | {name: '_fs_esc_attr_echo'}, |
||
| 67 | {name: '_fs_esc_html'}, |
||
| 68 | {name: '_fs_esc_html_echo'}, |
||
| 69 | {name: '_fs_ex', context: 2}, |
||
| 70 | {name: '_fs_esc_attr_x', context: 2}, |
||
| 71 | {name: '_fs_esc_html_x', context: 2}, |
||
| 72 | |||
| 73 | {name: '_fs_n', plural: 2}, |
||
| 74 | {name: '_fs_n_noop', plural: 2}, |
||
| 75 | {name: '_fs_nx', plural: 2, context: 4}, |
||
| 76 | {name: '_fs_nx_noop', plural: 2, context: 3}*/ |
||
| 77 | ] |
||
| 78 | })) |
||
| 79 | .pipe(gulp.dest(languagesFolder + 'freemius.pot')); |
||
| 80 | |||
| 81 | // Create English PO out of the POT. |
||
| 82 | return gulp.src(languagesFolder + 'freemius.pot') |
||
| 83 | .pipe(pofill({ |
||
| 84 | items: function (item) { |
||
| 85 | // If msgstr is empty, use identity translation |
||
| 86 | if (!item.msgstr.length) { |
||
| 87 | item.msgstr = ['']; |
||
| 88 | } |
||
| 89 | if (!item.msgstr[0]) { |
||
| 90 | item.msgstr[0] = item.msgid; |
||
| 91 | } |
||
| 92 | return item; |
||
| 93 | } |
||
| 94 | })) |
||
| 95 | .pipe(rename('freemius-en.po')) |
||
| 96 | .pipe(gulp.dest(languagesFolder)); |
||
| 97 | }); |
||
| 98 | |||
| 99 | // Push updated po resource to transifex. |
||
| 100 | gulp.task('update-transifex', ['prepare-source'], function () { |
||
| 101 | return gulp.src(languagesFolder + 'freemius-en.po') |
||
| 102 | .pipe(transifex.pushResource()); |
||
| 103 | }); |
||
| 104 | |||
| 105 | // Download latest *.po translations. |
||
| 106 | gulp.task('download-translations', ['update-transifex'], function () { |
||
| 107 | return gulp.src(languagesFolder + 'freemius-en.po') |
||
| 108 | .pipe(transifex.pullResource()); |
||
| 109 | }); |
||
| 110 | |||
| 111 | // Move translations to languages root. |
||
| 112 | gulp.task('prepare-translations', ['download-translations'], function () { |
||
| 113 | var folders = getFolders(languagesFolder); |
||
| 114 | |||
| 115 | return folders.map(function (folder) { |
||
| 116 | return gulp.src(path.join(languagesFolder, folder, 'freemius-en.po')) |
||
| 117 | .pipe(rename('freemius-' + folder + '.po')) |
||
| 118 | .pipe(gulp.dest(languagesFolder)); |
||
| 119 | }); |
||
| 120 | }); |
||
| 121 | |||
| 122 | // Feel up empty translations with English. |
||
| 123 | gulp.task('translations-feelup', ['prepare-translations'], function () { |
||
| 124 | return gulp.src(languagesFolder + '*.po') |
||
| 125 | .pipe(pofill({ |
||
| 126 | items: function (item) { |
||
| 127 | // If msgstr is empty, use identity translation |
||
| 128 | if (0 == item.msgstr.length) { |
||
|
0 ignored issues
–
show
|
|||
| 129 | item.msgstr = ['']; |
||
| 130 | } |
||
| 131 | if (0 == item.msgstr[0].length) { |
||
|
0 ignored issues
–
show
It is recommended to use
=== to compare with 0.
Generally, it is recommended to use strict comparison whenever possible and not to rely on the weaker type-juggling comparison operator. Loading history...
|
|||
| 132 | // item.msgid[0] = item.msgid; |
||
| 133 | item.msgstr[0] = item.msgid; |
||
| 134 | } |
||
| 135 | return item; |
||
| 136 | } |
||
| 137 | })) |
||
| 138 | .pipe(gulp.dest(languagesFolder)); |
||
| 139 | }); |
||
| 140 | |||
| 141 | // Cleanup temporary translation folders. |
||
| 142 | gulp.task('cleanup', ['prepare-translations'], function () { |
||
| 143 | var folders = getFolders(languagesFolder); |
||
| 144 | |||
| 145 | return folders.map(function (folder) { |
||
| 146 | return gulp.src(path.join(languagesFolder, folder), {read: false}) |
||
| 147 | .pipe(clean()); |
||
| 148 | }); |
||
| 149 | }); |
||
| 150 | |||
| 151 | // Compile *.po to *.mo binaries for usage. |
||
| 152 | gulp.task('compile-translations', ['translations-feelup'], function () { |
||
| 153 | // Compile POs to MOs. |
||
| 154 | return gulp.src(languagesFolder + '*.po') |
||
| 155 | .pipe(gettext()) |
||
| 156 | .pipe(gulp.dest(languagesFolder)) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 157 | }); |
||
| 158 | |||
| 159 | gulp.task('default', [], function () { |
||
| 160 | gulp.run('prepare-source'); |
||
| 161 | gulp.run('update-transifex'); |
||
| 162 | gulp.run('download-translations'); |
||
| 163 | gulp.run('prepare-translations'); |
||
| 164 | gulp.run('translations-feelup'); |
||
| 165 | gulp.run('cleanup'); |
||
| 166 | gulp.run('compile-translations'); |
||
| 167 | }); |
Generally, it is recommended to use strict comparison whenever possible and not to rely on the weaker type-juggling comparison operator.
Read more about comparison operations.