Search code examples
gettextgulppo

gulp: translations (gettext) only takes last .po file


I'm using gulp and gettext, all works well except when I have multiple .po files.

gulp.task('translations', function () {
    return gulp.src('app/po/*.po')
        .pipe($.gettext.compile())
        .pipe($.rename('translations.js'))
        .pipe(gulp.dest(dest));
    });

I have three .po files: lang1.po, lang2.po and lang3.po, and I only get lang3.po in translations.js. I guess this task is overwriting things. Any suggestions how I can cat everything together into translations.js ?


Solution

  • What you are doing here is:

    • step 1: compile lang1.po, compile lang2.po, compile lang3.po
    • step 2: rename lang1.po to translations.js, rename lang2.po to translations.js, rename lang3.po to translations.js

    Get the idea?

    You probably want to concat instead (using gulp-concat).

    gulp.task('translations', function () {
      return gulp.src('app/po/*.po')
        .pipe($.gettext.compile())
        .pipe(concat('translations.js')))
        .pipe(gulp.dest(dest));
    });
    

    Hope that helps.