{"version":3,"sources":["jsdelivr-header.js","/npm/xlf-auto-translate@1.0.34/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACDA,MAAM,KAAO,QAAQ,QACf,MAAQ,QAAQ,UAChB,cAAE,cAAa,eAAE,gBAAmB,QAAQ,sBAC5C,UAAY,QAAQ,eACpB,IAAM,QAAQ,iBAId,KAAO,QAAQ,SAChB,MACG,+GAEH,QACG,+EACA,gDAEH,QACG,oEACA,iDAEH,OAAO,IAAK,CACT,MAAO,KACP,QAAQ,EACR,SAAU,mCACV,KAAM,WAET,OAAO,IAAK,CACT,MAAO,MACP,QAAQ,EACR,SAAU,yCACV,KAAM,WAET,OAAO,IAAK,CACT,MAAO,OACP,QAAQ,EACR,SAAU,sCACV,KAAM,WAET,OAAO,IAAK,CACT,MAAO,KACP,QAAQ,EACR,SAAU,oCACV,KAAM,WAET,OAAO,IAAK,CACT,MAAO,OACP,QAAQ,EACR,SACI,kJACJ,KAAM,SACN,QAAS,MAEZ,OAAO,IAAK,CACT,MAAO,aACP,QAAQ,EACR,SACI,wHACJ,KAAM,SACN,QAAS,IAEZ,OAAO,IAAK,CACT,MAAO,QACP,QAAQ,EACR,SAAU,YACV,KAAM,WAET,OAAO,KAAM,CACV,MAAO,YACP,QAAQ,EACR,SAAU,iBACV,KAAM,UACN,SAAS,IAEZ,OAAO,IAAK,CACT,MAAO,OACP,QAAQ,EACR,SACI,0EACJ,KAAM,UACN,SAAS,IAEZ,OAAO,KAAM,CACV,MAAO,aACP,QAAQ,EACR,SAAU,8BACV,KAAM,UACN,SAAS,IAEZ,OAAO,cAAe,CACnB,MAAO,0BACP,QAAQ,EACR,SAAU,sFACV,KAAM,UACN,SAAS,IACV,KAID,UAAY,KAAK,MAGvB,cAAc,KAAK,QAAQ,KAAK,KAE3B,MAAM,GACI,UACH,EAAI,WACJ,KAAK,KACL,KAAK,GACL,KAAK,KACL,KAAK,WACL,KAAK,KACL,KAAK,MACL,KAAK,UACL,KAAK,WACL,KAAK,2BAKZ,MAAM,IACH,KAAK,mBAAqB,EAAK,mBACxB,eAAe,KAAK,QAAQ,KAAK,KAAM,EAAK,QAItD,MAAK,KACF,QAAQ,IAAI,0BAA2B,KAAK,oBAC5C,MAAM,EAAU,KAAK,MACrB,IACI,MAAM,MAAM,KACR,yBACA,KAAK,mBACL,iBACA,KAAK,GACL,QACC,EAAU,WACX,MACP,IAIJ,OAAO,IACJ,IACI,MAAM,IAAI,KACN,2CACA,KAAK,GACL,KAER,IAAI,GAAK,EAAI,MAAM","file":"/npm/xlf-auto-translate@1.0.34/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/xlf-auto-translate@1.0.34/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#! /usr/bin/env node\r\n\r\n/*\r\n    For usage help, run \"node index.js help\"\r\n*/\r\nconst path = require('path');\r\nconst chalk = require('chalk');\r\nconst { readFileAsync, writeFileAsync } = require('./helpers/fs-async');\r\nconst translate = require('./translate');\r\nconst log = require('./helpers/log');\r\n\r\n\r\n// setup up the command line interface\r\nconst argv = require('yargs')\r\n    .usage(\r\n        'xlf-auto-translate [options] \\nTranslates all property values in an .xlf file from one language to another.'\r\n    )\r\n    .example(\r\n        'xlf-auto-translate --in messages.xlf --out messages.hi.xlf --from en --to nl',\r\n        'Translate an .xlf file from English to Dutch'\r\n    )\r\n    .example(\r\n        'xlf-auto-translate -i messages.xlf -o messages.fr.xlf -f en -t fr',\r\n        'Translate an .xlf file from English to French'\r\n    )\r\n    .option('i', {\r\n        alias: 'in',\r\n        demand: true,\r\n        describe: 'The input .xlf file to translate',\r\n        type: 'string',\r\n    })\r\n    .option('o', {\r\n        alias: 'out',\r\n        demand: true,\r\n        describe: 'The name of the translated output file',\r\n        type: 'string',\r\n    })\r\n    .option('f', {\r\n        alias: 'from',\r\n        demand: true,\r\n        describe: 'The language code of the input file',\r\n        type: 'string',\r\n    })\r\n    .option('t', {\r\n        alias: 'to',\r\n        demand: true,\r\n        describe: 'The language code to translate to',\r\n        type: 'string',\r\n    })\r\n    .option('r', {\r\n        alias: 'rate',\r\n        demand: false,\r\n        describe:\r\n            'How long to wait after launching a job before launching another one in ms. For more information see https://github.com/SGrondin/bottleneck#docs',\r\n        type: 'number',\r\n        default: 500,\r\n    })\r\n    .option('c', {\r\n        alias: 'concurrent',\r\n        demand: false,\r\n        describe:\r\n            'How many jobs can be executing at the same time. For more information see https://github.com/SGrondin/bottleneck#docs',\r\n        type: 'number',\r\n        default: 4,\r\n    })\r\n    .option('p', {\r\n        alias: 'proxy',\r\n        demand: false,\r\n        describe: 'Use proxy',\r\n        type: 'string',\r\n    })\r\n    .option('ap', {\r\n        alias: 'autoProxy',\r\n        demand: false,\r\n        describe: 'Use auto proxy',\r\n        type: 'boolean',\r\n        default: false,\r\n    })\r\n    .option('s', {\r\n        alias: 'skip',\r\n        demand: false,\r\n        describe:\r\n            'Skips translating and adds only target tag with boilerplate text inside',\r\n        type: 'boolean',\r\n        default: false,\r\n    })\r\n    .option('cs', {\r\n        alias: 'clearState',\r\n        demand: false,\r\n        describe: 'Clear state once translated',\r\n        type: 'boolean',\r\n        default: false,\r\n    })\r\n    .option('addApproved', {\r\n        alias: 'addApprovedToStateFinal',\r\n        demand: false,\r\n        describe: 'Add approved=\"true\" XML attribute to trans-unit with translation with state=\"final\"',\r\n        type: 'boolean',\r\n        default: false,\r\n    }).argv;\r\n\r\n// start a timer so that we can\r\n// report how long the whole process took\r\nconst startTime = Date.now();\r\n\r\n// get the input .xlf file from the filesystem\r\nreadFileAsync(path.resolve(argv.in))\r\n    // translate the file\r\n    .then((xlf) => {\r\n        return translate(\r\n            xlf.toString(),\r\n            argv.from,\r\n            argv.to,\r\n            argv.rate,\r\n            argv.concurrent,\r\n            argv.skip,\r\n            argv.proxy,\r\n            argv.autoProxy,\r\n            argv.clearState,\r\n            argv.addApprovedToStateFinal\r\n        );\r\n    })\r\n\r\n    // write the result to the output file\r\n    .then((resp) => {\r\n        this.numberOfTranslated = resp.numberOfTranslated;\r\n        return writeFileAsync(path.resolve(argv.out), resp.xml);\r\n    })\r\n\r\n    // write a cheery message to the console\r\n    .then(() => {\r\n        console.log('this.numberOfTranslated', this.numberOfTranslated);\r\n        const endTime = Date.now();\r\n        log(\r\n            chalk.green('✓') +\r\n                ' Finished translating ' +\r\n                this.numberOfTranslated +\r\n                ' messages for ' +\r\n                argv.in +\r\n                ' in ' +\r\n                (endTime - startTime) +\r\n                'ms.'\r\n        );\r\n    })\r\n\r\n    // or, if something went wrong,  a grumpy one\r\n    .catch((err) => {\r\n        log(\r\n            chalk.red('X') +\r\n                ' Something went wrong while translating ' +\r\n                argv.in +\r\n                '!'\r\n        );\r\n        log('' + err.stack);\r\n    });\r\n"]}