Multi-language app -> Angular-gettext: how to update po files?

852 views Asked by At

I am building an angular app, with internationalization using angular-gettext. I would like to know how to better automate the workflow when updating the translation files.

Currently it is the following: - running "grunt" (generation of pot file + translation files) - opening all "po" files in poedit - in poedit, update po file with the new "pot" file - update translations in poedit & save - run grunt again

Is there a way to have something better? Like, is it possible to apply the pot file to all "po" files using a grunt command?

Here is my gruntfile currently. Thanks a lot

module.exports = function(grunt) 
{
    grunt.initConfig({
          nggettext_extract: {
            pot: {
              files: {
                'po/template.pot': ['www/app/**/*.html']
              }
            },
          },
          nggettext_compile: {
            all: {
              options: {
                module: 'app'
              },
              files: {
                'www/resources/translations.js': ['po/*.po']
              }
            },
          }
        });

    grunt.loadNpmTasks('grunt-angular-gettext');

    // Default task(s).
    grunt.registerTask('default', ['nggettext_extract', 'nggettext_compile']);
}
2

There are 2 answers

0
Austin Thompson On

Actually there is a way to do this!

We wrote grunt tasks to call command line gettext utilities. They are also available for windows here.

Basically you need to call msgmerge with the po file and the pot file to update it. See the online documentation for msgmerge to see what you may need. It's pretty slick once you get it going.

0
Gaetan On

poedit doesn't have a command line argument to execute the "Update from pot" file feature. So I don't think it will be possible with it.