1

I am using grunt and grunt-angular-gettext with my angularJS project.
I would like to let grunt run grunt task nggettext_extract whenever a source file is updated, and nggettext_compile whenever a 'po' file is updated.
I thought I could just add the tasks names to my 'grunt.task.run' tasks list, this way:

...
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
  grunt.task.run([
    'nggettext_extract', <== added task, just executed on the first run
    'nggettext_compile', <== added task, just executed on the first run
    'clean:server',
    'wiredep',
    'concurrent:server',
    'autoprefixer',
    'connect:livereload',
    'watch'
  ]);
});
...

but unfortunately this works only for the first grunt run, and not afterwards... It would even be acceptable for me to have both tasks run whenever any file changes in my project (I am not sure how to specify dependencies within Gruntfile.js, I'm quite new with it... :-().

If it can be of any help, these are my nggettext_ tasks configurations (quite standard):

   ...

   nggettext_extract: {
      pot: {
        files: {
          'po/template.pot': [ 'app/**/*.html', 'app/scripts/**/*.js' ]
        }
      }
    },

    nggettext_compile: {
      all: {
        files: {
          'app/scripts/translations.js': ['po/*.po']
        }
      }
    },

    ...
MarcoS
  • 17,323
  • 24
  • 96
  • 174

1 Answers1

0

I think something similar to this in your gruntfile should work:

 ...
 watch: {
  po-changed: {
    files: ["po/*.po"],
    tasks: ["nggettext_compile"],
  },
  update-pot: {
    files: ['app/**/*.html', 'app/scripts/**/*.js'],
    tasks: ["nggettext_extract"],
  },
 },
 ...
Austin Thompson
  • 2,251
  • 1
  • 17
  • 23
  • Thanks! I did already solved this issue myself, but your answer is correct. I did also add a supplementary task (`tasks: ['nggettext_extract', 'po_auto_translate' ]`) to `update-pot` watch, to run a script of mine to auto-translate missing entries, as an aid to human translators... – MarcoS Oct 14 '14 at 07:14