Automatically patch translations with placeholders
fixes #630 // FREEBIE
This commit is contained in:
parent
df03f839b1
commit
c5a9714a0a
1 changed files with 21 additions and 1 deletions
22
Gruntfile.js
22
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']);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue