diff --git a/Gruntfile.js b/Gruntfile.js index 576447eb..45aecffd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -197,8 +197,28 @@ module.exports = function(grunt) { } }); + // Transifex does not understand placeholders, so this task patches all non-en + // locales with missing placeholders + grunt.registerTask('locale-patch', function(){ + var en = grunt.file.readJSON('_locales/en/messages.json'); + grunt.file.recurse('_locales', function(abspath, rootdir, subdir, filename){ + if (subdir === 'en' || filename !== 'messages.json'){ + return; + } + var messages = grunt.file.readJSON(abspath); + + for (var key in messages){ + if (en[key]['placeholders'] !== undefined && messages[key]['placeholders'] === undefined){ + messages[key]['placeholders'] = en[key]['placeholders'] + } + } + + grunt.file.write(abspath, JSON.stringify(messages, null, 4) + '\n'); + }); + }); + grunt.registerTask('dev', ['default', 'connect', 'watch']); grunt.registerTask('test', ['jshint', 'jscs', 'connect', 'saucelabs-mocha']); - grunt.registerTask('default', ['concat', 'sass', 'copy']); + grunt.registerTask('default', ['concat', 'sass', 'locale-patch', 'copy']); };