Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const messageKeys = Object.keys(messages);
messageKeys.forEach(messageKey => {
oldLocaleMappings[locale][messageKey] = messages[messageKey];
});
} catch (error) {
if (error.code !== 'ENOENT') {
process.stderr.write(
`There was an error loading this translation file: ${translationFileName}
\n${error}`
);
}
}
});
// eslint-disable-next-line global-require
plugins.push([require('babel-plugin-react-intl').default]);
const sortMessages = localeMessages => {
// Sort the translation JSON file so that git diffing is easier
// Otherwise the translation messages will jump around every time we extract
const sortedMessages = {};
Object.keys(localeMessages)
// transform strings to lowercase to imitate phraseapp sorting
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.forEach(key => {
sortedMessages[key] = localeMessages[key];
});
return sortedMessages;
};
const extractFromFile = async fileName => {
try {
],
// function* () { yield 42; yield 43; }
!isEnvTest && [
require('@babel/plugin-transform-regenerator').default,
{
// Async functions are converted to generators by @babel/preset-env
async: false,
},
],
// Adds syntax support for import()
require('@babel/plugin-syntax-dynamic-import').default,
isEnvTest &&
// Transform dynamic import to require
require('babel-plugin-transform-dynamic-import').default,
// Extract intl messages
require('babel-plugin-react-intl').default,
].filter(Boolean),
};
};