diff --git a/Gruntfile.js b/Gruntfile.js index dcad7d3dfc..71896d84a4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,24 +1,59 @@ module.exports = function(grunt) { + var _ = grunt.util._; + var locales = ["bg_BG", "ca_ES", "cs_CZ", "de_DE", "es_AR", "es_CO", "es_EC", + "es_ES", "fr_FR", "ja_JP", "lt_LT", "nl_NL", "ru_RU", "sl_SI"]; + var jsfiles = [ + 'src/sao.js', + 'src/rpc.js', + 'src/pyson.js', + 'src/session.js', + 'src/model.js', + 'src/tab.js', + 'src/screen.js', + 'src/view.js', + 'src/action.js', + 'src/common.js', + 'src/window.js', + 'src/wizard.js' + ]; + // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + xgettext: { + locale: { + files: { + javascript: jsfiles + }, + options: { + functionName: "Sao.i18n.gettext", + potFile: "locale/messages.pot" + }, + } + }, + shell: { + options: { + failOnError: true + }, + msgmerge: { + command: _.map(locales, function(locale) { + var po = "locale/" + locale + ".po"; + return "msgmerge -U " + po + " locale/messages.pot;"; + }).join("") + }, + po2json: { + command: _.map(locales, function(locale) { + var po = "locale/" + locale + ".po"; + var json = "locale/" + locale + ".json"; + return "./node_modules/.bin/po2json-gettextjs " + + po + " " + json + ";"; + }).join("") + } + }, concat: { dist: { - src: [ - 'src/sao.js', - 'src/rpc.js', - 'src/pyson.js', - 'src/session.js', - 'src/model.js', - 'src/tab.js', - 'src/screen.js', - 'src/view.js', - 'src/action.js', - 'src/common.js', - 'src/window.js', - 'src/wizard.js' - ], + src: jsfiles, dest: 'dist/<%= pkg.name %>.js' } }, @@ -85,6 +120,8 @@ module.exports = function(grunt) { // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-xgettext'); + grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-less'); @@ -93,5 +130,7 @@ module.exports = function(grunt) { // Default task(s). grunt.registerTask('default', ['concat', 'jshint', 'uglify', 'less:default']); grunt.registerTask('dev', ['concat', 'jshint', 'less:dev']); + grunt.registerTask('msgmerge', ['shell:msgmerge']); + grunt.registerTask('po2json', ['shell:po2json']); }; diff --git a/bower.json b/bower.json index aa29e0d112..419b124bd2 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,8 @@ "moment": "~2.10.2", "eonasdan-bootstrap-datetimepicker": "~4.7.14", "typeahead.js": "~0.10.5", - "typeahead.js-bootstrap3.less": "~0" + "typeahead.js-bootstrap3.less": "~0", + "gettext.js": "~0.5.0" }, "devDependencies": { "qunit": "~1.18.0" diff --git a/index.html b/index.html index 03c8da8f9b..3158747424 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,7 @@ this repository contains the full copyright notices and license terms. --> + @@ -76,49 +77,5 @@ this repository contains the full copyright notices and license terms. --> Sao.login(); }); -