Commit 65c6a4ac308acbb68add3e8c68e11875752e5d4e

Authored by Victor Costa
Committed by Michel Felipe
1 parent 8a1cb95c

Merge plugin languages when building with gulp

gulp/build.js
... ... @@ -6,6 +6,7 @@ var rename = require('gulp-rename');
6 6 var insert = require('gulp-insert');
7 7 var merge = require('merge-stream');
8 8 var conf = require('./conf');
  9 +var languages = require('./languages');
9 10  
10 11 var themeName = conf.paths.theme.replace('-', ' ');
11 12 themeName = themeName.charAt(0).toUpperCase() + themeName.slice(1);
... ... @@ -130,6 +131,10 @@ gulp.task('clean-docs', [], function() {
130 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 138 gulp.task('noosfero', ['html'], function () {
134 139 var layouts = gulp.src('layouts/**/*')
135 140 .pipe(gulp.dest(path.join(conf.paths.dist, "layouts")));
... ... @@ -142,4 +147,4 @@ gulp.task('noosfero', ['html'], function () {
142 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 20 tmp: '.tmp',
21 21 e2e: 'e2e',
22 22 docs: 'docs',
23   - themes: 'themes'
  23 + themes: 'themes',
  24 + languages: 'languages'
24 25 };
25 26 exports.configTheme = function(theme) {
26 27 exports.paths.theme = theme || "angular-default";
... ...
gulp/languages.js 0 → 100644
... ... @@ -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 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 49 var srcPaths = [path.join(conf.paths.tmp, '/serve')];
50 50 conf.paths.allSources.reverse().forEach(function(src) {
51 51 srcPaths.push(src);
... ...
gulp/watch.js
... ... @@ -3,6 +3,7 @@
3 3 var path = require('path');
4 4 var gulp = require('gulp');
5 5 var conf = require('./conf');
  6 +var languages = require('./languages');
6 7  
7 8 var browserSync = require('browser-sync');
8 9  
... ... @@ -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 42 var watchPaths = [];
38 43 conf.paths.allSources.forEach(function(src) {
39 44 watchPaths.push(path.join(src, '/app/**/*.html'));
... ...
package.json
... ... @@ -49,6 +49,7 @@
49 49 "gulp-insert": "^0.5.0",
50 50 "gulp-inject": "~3.0.0",
51 51 "gulp-load-plugins": "~0.10.0",
  52 + "gulp-merge-json": "^0.4.0",
52 53 "gulp-minify-css": "~1.2.1",
53 54 "gulp-minify-html": "~1.0.4",
54 55 "gulp-ng-annotate": "~1.1.0",
... ...
src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html
1 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 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>
... ...
src/plugins/comment_paragraph/languages/en.json 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +{
  2 + "comment-paragraph-pluging.activate": "Activate paragraph comments",
  3 + "comment-paragraph-pluging.deactivate": "Deactivate paragraph comments"
  4 +}
... ...
src/plugins/comment_paragraph/languages/pt.json 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +{
  2 + "comment-paragraph-pluging.activate": "Ativar comentários por parágrafo",
  3 + "comment-paragraph-pluging.deactivate": "Desativar comentários por parágrafo"
  4 +}
... ...