When you have a folder that has more than one po file for the same data, the final file overwrites on the same key making a JSON file with only one translation.
Reproduce
Files:
- foo/fr_CA.po
- foo/en_UK.po
Config block:
grunt.initConfig({
po2json: {
files: {
options: {},
files: {
'assets/i18n/foo.json': [ 'foo/*.po' ]
}
}
});
Expected outcome
In file assets/i18n/foo.json
exports.I18N = {
"fr_CA": {
"Untrash": "Sortir de la Corbeille"
},
"en_UK": {
"Untrash": "Untrash"
}
}
Solution path
Read from the file name. Use it as a key
// file tasks/po2json.js, line 48
var locale = filepath.substr(filepath.lastIndexOf('/') + 1).replace(/\.[^/.]+$/,'');
When you have a folder that has more than one po file for the same data, the final file overwrites on the same key making a JSON file with only one translation.
Reproduce
Files:
Config block:
Expected outcome
In file
assets/i18n/foo.jsonSolution path
Read from the file name. Use it as a key