Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function saveTranslations( packageName, translations ) {
const languageCodeMap = require( './languagecodemap.json' );
let savedTranslations = 0;
for ( let [ lang, poFileContent ] of translations ) {
if ( !isPoFileContainingTranslations( poFileContent ) ) {
continue;
}
if ( lang in languageCodeMap ) {
lang = languageCodeMap[ lang ];
}
poFileContent = cleanPoFileContent( poFileContent );
const pathToSave = path.join( process.cwd(), 'packages', packageName, 'lang', 'translations', lang + '.po' );
fs.outputFileSync( pathToSave, poFileContent );
savedTranslations++;
}
logger.info( `Saved ${ savedTranslations } PO files for ${ packageName } package.` );
}