Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function loader(source) {
- if (this.cacheable) this.cacheable();
- let value = typeof source === 'string' ? JSON.parse(source) : source;
- // Filter out smartling metadata.
- const metadata = value.smartling;
- if (metadata !== undefined) {
- const path = metadata.translate_paths.path.split('/')[1];
- delete value.smartling;
- Object.keys(value).forEach((key) => {
- value[key] = value[key][path];
- });
- }
- value = JSON.stringify(value)
- .replace(/\u2028/g, '\\u2028')
- .replace(/\u2029/g, '\\u2029');
- return `module.exports = ${value}`;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement