mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-27 01:02:14 +05:30
22 lines
633 B
JavaScript
22 lines
633 B
JavaScript
module.exports = function(content) {
|
|
this.cacheable && this.cacheable();
|
|
content = JSON.parse(content);
|
|
|
|
const moduleId = this.context
|
|
.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 + ')';
|
|
};
|