2017-08-01 23:01:47 +05:30
|
|
|
module.exports = function(content) {
|
2016-05-09 00:58:51 +05:30
|
|
|
this.cacheable && this.cacheable();
|
2017-08-01 23:01:47 +05:30
|
|
|
content = JSON.parse(content);
|
2016-05-09 00:58:51 +05:30
|
|
|
|
2017-08-01 23:01:47 +05:30
|
|
|
const moduleId = this.context
|
2016-05-09 00:58:51 +05:30
|
|
|
.replace(this.options.resolve.root, '')
|
|
|
|
.replace(/^\/|\/$/g, '')
|
|
|
|
.replace(/\//g, '.');
|
|
|
|
|
|
|
|
content = JSON.stringify(Object.keys(content).reduce(function(translations, key) {
|
|
|
|
translations[key] = {
|
|
|
|
id: moduleId + '.' + key,
|
|
|
|
defaultMessage: content[key]
|
|
|
|
};
|
|
|
|
|
|
|
|
return translations;
|
|
|
|
}, {}));
|
|
|
|
|
|
|
|
return 'import { defineMessages } from \'react-intl\';'
|
|
|
|
+ 'export default defineMessages(' + content + ')';
|
|
|
|
};
|