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jB,EAKA,oBAAoB,UAAU,wCAA0C,SAAU,GAE9E,MAAM,UAAU,CACX,IACG,MAAM,EAAU,GAAG,WAAW,UAAU,cACxC,iBAAiB,cAAc,GAAS,CAAC,EAAK,KAE1C,IAAK,EACD,OAAO,EAAS,OAAO,sBAAsB,aAGjD,EAAS,EAAI,GAChB,EAEJ,IACG,MAAM,EAAU,GAAG,WAAW,UAAU,eACxC,iBAAiB,cAAc,GAAS,CAAC,EAAK,KAE1C,IAAK,EACD,OAAO,EAAS,OAAO,iBAAiB,aAG5C,EAAS,EAAI,GACf,EAEL,IAEG,MAAM,UAAU,CAEX,IACG,MAAM,EAAO,GAAG,UAAU,iBAAiB,SAC3C,iBAAiB,cAAc,GAAM,CAAC,EAAK,KAEvC,IAAK,EACD,OAAO,EAAS,OAAO,+BAG3B,EAAS,EAAI,GAChB,EAEJ,IAEG,iBAAiB,iBAAiB,GAAG,UAAU,iBAAiB,cAAe,IAC3E,EAAS,EAAI,GACf,EAEL,IAEG,iBAAiB,iBAAiB,GAAG,UAAU,iBAAiB,uBAAwB,IACpF,EAAS,EAAI,GACf,EAEL,IAEG,iBAAiB,iBAAiB,GAAG,UAAU,iBAAiB,2BAA4B,IACxF,EAAS,EAAI,GACf,EAEL,IAEG,iBAAiB,iBAAiB,GAAG,UAAU,iBAAiB,+BAAgC,IAC5F,EAAS,EAAI,GACf,IAEN,IACA,EAAS,EAAI,GAChB,IAEL,IACA,EAAS,EAAI,GAErB,EAGA,OAAO,QAAU,IAAI","file":"/npm/xlf-translator@1.0.30/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/xlf-translator@1.0.30/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","const xlfFileProcessor = require('./lib/xlf-file-processor');\nconst xlfProcessor = require('./lib/xlf-processor');\nconst constants = require('./lib/constants');\nconst errors = require('./lib/errors');\nconst async = require('async');\nconst chalk = require('chalk');\nconst logSymbols = require('log-symbols');\n\n\nfunction XlrTranslatorModule() {\n    //constructor\n}\n\n\n/**\n * Check for missing files and translate this with the google api\n * @param messageOutputFileDir\n * @param callback\n */\nXlrTranslatorModule.prototype.handleMissingTranslationMessageFiles = function (messageOutputFileDir, callback) {\n    // check if there ara missing files\n    async.waterfall([\n        (callback) => {\n            xlfFileProcessor.listFiles(messageOutputFileDir, (err, files) => {\n                callback(err, files);\n            });\n        },\n        (files, callback) => {\n            const missingTranslations = [];\n            const translationLocales = translatorConfig.toLanguage;\n            const filesLocales = files.map((file) => file.split('.')[1]);\n            translationLocales.forEach((translationLocale) => {\n                if (filesLocales.indexOf(translationLocale) === -1) {\n                    missingTranslations.push(translationLocale);\n                }\n            });\n\n            if (!missingTranslations.length) {\n                console.log(logSymbols.success, chalk.gray('No missing files, continue checking for updates'));\n                return callback();\n            }\n\n            console.log(logSymbols.success, chalk.gray(`Found missing files, added -> ${missingTranslations.join(', ')} files`));\n            xlfProcessor.translateAndProcessFilesWithGoogleApi(missingTranslations, (err) => {\n                return callback(err, 'updated');\n            });\n        }\n    ], (err) => {\n        callback(err);\n    })\n};\n\n/**\n * Main start translating method, this will check if stuff already exists\n */\nXlrTranslatorModule.prototype.startTranslating = function (done) {\n\n    const messageOutputFileDir = `${appRoot}${translatorConfig.outputPath}/messages`;\n    async.waterfall([\n\n        (callback) => {\n            xlfFileProcessor.listFiles(messageOutputFileDir, (err, files) => {\n\n                // if no files were found create new ones\n                if (!files.length) {\n                    console.log(logSymbols.info, chalk.blue('Did not find any existing translations, started translating with google ...\\n'));\n                    xlfProcessor.translateAndProcessFilesWithGoogleApi(translatorConfig.toLanguage, (err) => {\n                        return done(err);\n                    });\n                } else {\n                    // check if there are new or missing files\n                    console.log(logSymbols.info, chalk.blue('Found existing translations\\n'));\n                    this.handleMissingTranslationMessageFiles(messageOutputFileDir, (err) => {\n                        callback(err);\n                    })\n                }\n            });\n        },\n        (callback) => {\n            xlfProcessor.handleExistingMessages((err) => {\n                callback(err);\n            });\n        }\n    ], (err) => {\n        done(err);\n    })\n};\n\n/**\n * Prepare before starting, check if there is a config file else add one, and that it has the need constants\n */\nXlrTranslatorModule.prototype.validateFilesAndPrepareBeforeProcessing = function (callback) {\n\n    async.waterfall([\n        (callback) => {\n            const dirPath = `${appRoot}/${constants.CONFIG_NAME}`;\n            xlfFileProcessor.doesFileExist(dirPath, (err, doesExist) => {\n\n                if (!doesExist) {\n                    return callback(errors.CONFIG_FILE_NOT_EXIST.description)\n                }\n\n                callback(err);\n            })\n        },\n        (callback) => {\n            const dirPath = `${appRoot}/${constants.PACKAGE_JSON}`;\n            xlfFileProcessor.doesFileExist(dirPath, (err, doesExist) => {\n\n                if (!doesExist) {\n                    return callback(errors.NOT_IN_A_PROJECT.description)\n                }\n\n                callback(err);\n            });\n        },\n        (callback) => {\n\n            async.waterfall([\n\n                (callback) => {\n                    const file = `${appRoot}${translatorConfig.source}`;\n                    xlfFileProcessor.doesFileExist(file, (err, doesExist) => {\n\n                        if (!doesExist) {\n                            return callback(errors.CONFIG_MESSAGE_FILE_NOT_EXIST);\n                        }\n\n                        callback(err);\n                    })\n                },\n                (callback) => {\n                    // check if locale directory is present\n                    xlfFileProcessor.dirExistOrCreate(`${appRoot}${translatorConfig.outputPath}`, (err) => {\n                        callback(err);\n                    });\n                },\n                (callback) => {\n                    // check if message directory is present\n                    xlfFileProcessor.dirExistOrCreate(`${appRoot}${translatorConfig.outputPath}/messages`, (err) => {\n                        callback(err);\n                    });\n                },\n                (callback) => {\n                    // check if translations directory is present\n                    xlfFileProcessor.dirExistOrCreate(`${appRoot}${translatorConfig.outputPath}/translations`, (err) => {\n                        callback(err);\n                    });\n                },\n                (callback) => {\n                    // check if translations directory is present\n                    xlfFileProcessor.dirExistOrCreate(`${appRoot}${translatorConfig.outputPath}/translations/csv`, (err) => {\n                        callback(err);\n                    });\n                }\n            ], (err) => {\n                callback(err);\n            })\n        }\n    ], (err) => {\n        callback(err);\n    });\n};\n\n\nmodule.exports = new XlrTranslatorModule();\n"]}