From ac40efd078f0a731c1eb9b5b6a31637895fec86c Mon Sep 17 00:00:00 2001 From: schubc Date: Thu, 8 Aug 2024 10:24:43 +0200 Subject: [PATCH] Add language support for rendering errors and progress logs Introduce a new `--language` flag to specify the language of local After Effects installation. Currently, support is added for English and German, which affects error and progress log parsing. --- packages/nexrender-core/src/tasks/render.js | 29 +++++++++++++++++---- packages/nexrender-worker/src/bin.js | 7 +++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/nexrender-core/src/tasks/render.js b/packages/nexrender-core/src/tasks/render.js index 2a9b6b95..f0355574 100644 --- a/packages/nexrender-core/src/tasks/render.js +++ b/packages/nexrender-core/src/tasks/render.js @@ -3,11 +3,19 @@ const path = require('path') const {spawn} = require('child_process') const {expandEnvironmentVariables, checkForWSL} = require('../helpers/path') -const progressRegex = /([\d]{1,2}:[\d]{2}:[\d]{2}:[\d]{2})\s+(\(\d+[UL]?\))/gi; -const durationRegex = /Duration:\s+([\d]{1,2}:[\d]{2}:[\d]{2}:[\d]{2})/gi; -const startRegex = /Start:\s+([\d]{1,2}:[\d]{2}:[\d]{2}:[\d]{2})/gi; -const nexrenderErrorRegex = /Error:\s+(nexrender:.*)$/gim; -const errorRegex = /aerender Error:\s*(.*)$/gis; +const translations = { + "en": { + "duration": "Duration", + "error" : "Error", + "start" : "Start" + }, + "de": { + "duration": "Dauer", + "error" : "Fehler", + "start" : "Anfang" + } +}; + const option = (params, name, ...values) => { if (values !== undefined) { @@ -25,6 +33,17 @@ const seconds = (string) => string.split(':') module.exports = (job, settings) => { settings.logger.log(`[${job.uid}] rendering job...`); + if(!settings.language) { + settings.lang = "en" + } + + const progressRegex = /([\d]{1,2}:[\d]{2}:[\d]{2}:[\d]{2})\s+(\(\d+[UL]?\))/gi; + const durationRegex = new RegExp(translations[settings.language].duration + ":\\s+([\\d]{1,2}:[\\d]{2}:[\\d]{2}:[\\d]{2})", "gi"); + const startRegex = new RegExp(translations[settings.language].start + ":\\s+([\\d]{1,2}:[\\d]{2}:[\\d]{2}:[\\d]{2})", "gi"); + const nexrenderErrorRegex = new RegExp(translations[settings.language].error + ":\\s+(nexrender:.*)$", "gim"); + const errorRegex = new RegExp("aerender " + translations[settings.language].error + ":\\s*(.*)$", "gis"); + + // create container for our parameters let params = []; let outputFile = expandEnvironmentVariables(job.output) diff --git a/packages/nexrender-worker/src/bin.js b/packages/nexrender-worker/src/bin.js index 5402505c..3e540f34 100644 --- a/packages/nexrender-worker/src/bin.js +++ b/packages/nexrender-worker/src/bin.js @@ -46,6 +46,7 @@ const args = arg({ '--header': [String], '--aerender-parameter': [String], + '--language': String, // Aliases '-v': '--version', @@ -177,6 +178,8 @@ if (args['--help']) { --aerender-parameter, --ae forward parameter to aerender (see Adobe site). Parameters with arguments have to be enclosed in single quotes. For example: nexrender --aerender-parameter 'close SAVE_CHANGES' --ae 'i 10' job.json + + --language language of local after effects installation. currently only en and de are supported {bold ENV VARS} @@ -237,6 +240,7 @@ opt('polling', '--polling'); opt('wslMap', '--wsl-map'); opt('aeParams', '--aerender-parameter'); opt('tagSelector', '--tag-selector'); +opt('language', '--language'); if(args['--cache-path']){ opt('cache', '--cache-path'); @@ -271,6 +275,9 @@ if (settings['no-license']) { settings.addLicense = true; } +/* debug implies verbose */ +// settings.verbose = settings.debug; + if (settings['no-analytics']) { settings.noAnalytics = true; delete settings['no-analytics'];