Commit 65c6a4ac308acbb68add3e8c68e11875752e5d4e
Committed by
Michel Felipe

1 parent
8a1cb95c
Exists in
master
and in
26 other branches
Merge plugin languages when building with gulp
Showing
9 changed files
with
54 additions
and
5 deletions
Show diff stats
gulp/build.js
@@ -6,6 +6,7 @@ var rename = require('gulp-rename'); | @@ -6,6 +6,7 @@ var rename = require('gulp-rename'); | ||
6 | var insert = require('gulp-insert'); | 6 | var insert = require('gulp-insert'); |
7 | var merge = require('merge-stream'); | 7 | var merge = require('merge-stream'); |
8 | var conf = require('./conf'); | 8 | var conf = require('./conf'); |
9 | +var languages = require('./languages'); | ||
9 | 10 | ||
10 | var themeName = conf.paths.theme.replace('-', ' '); | 11 | var themeName = conf.paths.theme.replace('-', ' '); |
11 | themeName = themeName.charAt(0).toUpperCase() + themeName.slice(1); | 12 | themeName = themeName.charAt(0).toUpperCase() + themeName.slice(1); |
@@ -130,6 +131,10 @@ gulp.task('clean-docs', [], function() { | @@ -130,6 +131,10 @@ gulp.task('clean-docs', [], function() { | ||
130 | return $.del([path.join(conf.paths.docs, '/')]); | 131 | return $.del([path.join(conf.paths.docs, '/')]); |
131 | }); | 132 | }); |
132 | 133 | ||
134 | +gulp.task('plugin-languages', ['locale'], function() { | ||
135 | + return languages.pluginLanguages(conf.paths.dist); | ||
136 | +}); | ||
137 | + | ||
133 | gulp.task('noosfero', ['html'], function () { | 138 | gulp.task('noosfero', ['html'], function () { |
134 | var layouts = gulp.src('layouts/**/*') | 139 | var layouts = gulp.src('layouts/**/*') |
135 | .pipe(gulp.dest(path.join(conf.paths.dist, "layouts"))); | 140 | .pipe(gulp.dest(path.join(conf.paths.dist, "layouts"))); |
@@ -142,4 +147,4 @@ gulp.task('noosfero', ['html'], function () { | @@ -142,4 +147,4 @@ gulp.task('noosfero', ['html'], function () { | ||
142 | return merge(layouts, theme, index); | 147 | return merge(layouts, theme, index); |
143 | }); | 148 | }); |
144 | 149 | ||
145 | -gulp.task('build', ['html', 'fonts', 'other', 'locale', 'noosfero']); | 150 | +gulp.task('build', ['html', 'fonts', 'other', 'locale', 'plugin-languages', 'noosfero']); |
gulp/conf.js
@@ -20,7 +20,8 @@ exports.paths = { | @@ -20,7 +20,8 @@ exports.paths = { | ||
20 | tmp: '.tmp', | 20 | tmp: '.tmp', |
21 | e2e: 'e2e', | 21 | e2e: 'e2e', |
22 | docs: 'docs', | 22 | docs: 'docs', |
23 | - themes: 'themes' | 23 | + themes: 'themes', |
24 | + languages: 'languages' | ||
24 | }; | 25 | }; |
25 | exports.configTheme = function(theme) { | 26 | exports.configTheme = function(theme) { |
26 | exports.paths.theme = theme || "angular-default"; | 27 | exports.paths.theme = theme || "angular-default"; |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +'use strict'; | ||
2 | + | ||
3 | +var path = require('path'); | ||
4 | +var gulp = require('gulp'); | ||
5 | +var merge = require('merge-stream'); | ||
6 | +var conf = require('./conf'); | ||
7 | +var mergeJson = require('gulp-merge-json'); | ||
8 | +var glob = require("glob"); | ||
9 | + | ||
10 | +exports.pluginLanguages = function(dest) { | ||
11 | + var merged = merge(); | ||
12 | + glob(path.join(conf.paths.src, conf.paths.languages, "*.json"), function (er, files) { | ||
13 | + files.forEach(function(file) { | ||
14 | + merged.add(exports.pluginLanguage(file, dest)); | ||
15 | + }); | ||
16 | + }); | ||
17 | + return merged; | ||
18 | +} | ||
19 | + | ||
20 | +exports.pluginLanguage = function(file, dest) { | ||
21 | + var language = file.split('/').pop().replace('\.json',''); | ||
22 | + return gulp.src(path.join(conf.paths.src, '**', conf.paths.languages, language+'.json')) | ||
23 | + .pipe(mergeJson(path.join(conf.paths.languages, language+'.json'))) | ||
24 | + .pipe(gulp.dest(dest)) | ||
25 | +} | ||
26 | + | ||
27 | +gulp.task('serve-languages', function() { | ||
28 | + return exports.pluginLanguages(path.join(conf.paths.tmp, '/serve')); | ||
29 | +}); |
gulp/server.js
@@ -45,7 +45,7 @@ browserSync.use(browserSyncSpa({ | @@ -45,7 +45,7 @@ browserSync.use(browserSyncSpa({ | ||
45 | selector: '[ng-app]'// Only needed for angular apps | 45 | selector: '[ng-app]'// Only needed for angular apps |
46 | })); | 46 | })); |
47 | 47 | ||
48 | -gulp.task('serve', ['watch'], function () { | 48 | +gulp.task('serve', ['serve-languages', 'watch'], function () { |
49 | var srcPaths = [path.join(conf.paths.tmp, '/serve')]; | 49 | var srcPaths = [path.join(conf.paths.tmp, '/serve')]; |
50 | conf.paths.allSources.reverse().forEach(function(src) { | 50 | conf.paths.allSources.reverse().forEach(function(src) { |
51 | srcPaths.push(src); | 51 | srcPaths.push(src); |
gulp/watch.js
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | var path = require('path'); | 3 | var path = require('path'); |
4 | var gulp = require('gulp'); | 4 | var gulp = require('gulp'); |
5 | var conf = require('./conf'); | 5 | var conf = require('./conf'); |
6 | +var languages = require('./languages'); | ||
6 | 7 | ||
7 | var browserSync = require('browser-sync'); | 8 | var browserSync = require('browser-sync'); |
8 | 9 | ||
@@ -34,6 +35,10 @@ gulp.task('watch', ['inject'], function () { | @@ -34,6 +35,10 @@ gulp.task('watch', ['inject'], function () { | ||
34 | } | 35 | } |
35 | }); | 36 | }); |
36 | 37 | ||
38 | + gulp.watch(path.join(conf.paths.src, '**', conf.paths.languages, '*.json'), function(event) { | ||
39 | + languages.pluginLanguage(event.path, path.join(conf.paths.tmp, '/serve')); | ||
40 | + }); | ||
41 | + | ||
37 | var watchPaths = []; | 42 | var watchPaths = []; |
38 | conf.paths.allSources.forEach(function(src) { | 43 | conf.paths.allSources.forEach(function(src) { |
39 | watchPaths.push(path.join(src, '/app/**/*.html')); | 44 | watchPaths.push(path.join(src, '/app/**/*.html')); |
package.json
@@ -49,6 +49,7 @@ | @@ -49,6 +49,7 @@ | ||
49 | "gulp-insert": "^0.5.0", | 49 | "gulp-insert": "^0.5.0", |
50 | "gulp-inject": "~3.0.0", | 50 | "gulp-inject": "~3.0.0", |
51 | "gulp-load-plugins": "~0.10.0", | 51 | "gulp-load-plugins": "~0.10.0", |
52 | + "gulp-merge-json": "^0.4.0", | ||
52 | "gulp-minify-css": "~1.2.1", | 53 | "gulp-minify-css": "~1.2.1", |
53 | "gulp-minify-html": "~1.0.4", | 54 | "gulp-minify-html": "~1.0.4", |
54 | "gulp-ng-annotate": "~1.1.0", | 55 | "gulp-ng-annotate": "~1.1.0", |
src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html
1 | <a href='#' class="btn btn-default btn-xs" (click)="ctrl.activateCommentParagraph()" | 1 | <a href='#' class="btn btn-default btn-xs" (click)="ctrl.activateCommentParagraph()" |
2 | - ng-show="!ctrl.article.setting.comment_paragraph_plugin_activate">Enable</a> | 2 | + ng-show="!ctrl.article.setting.comment_paragraph_plugin_activate">{{"comment-paragraph-pluging.activate" | translate}}</a> |
3 | <a href='#' class="btn btn-default btn-xs" (click)="ctrl.deactivateCommentParagraph()" | 3 | <a href='#' class="btn btn-default btn-xs" (click)="ctrl.deactivateCommentParagraph()" |
4 | - ng-show="ctrl.article.setting.comment_paragraph_plugin_activate">Disable</a> | 4 | + ng-show="ctrl.article.setting.comment_paragraph_plugin_activate">{{"comment-paragraph-pluging.deactivate" | translate}}</a> |