Skip to content

Commit

Permalink
Merge pull request #1012 from schubc/translation
Browse files Browse the repository at this point in the history
Add language support for rendering errors and progress logs
  • Loading branch information
inlife authored Aug 8, 2024
2 parents 54a65af + ac40efd commit 545282f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
29 changes: 24 additions & 5 deletions packages/nexrender-core/src/tasks/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions packages/nexrender-worker/src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const args = arg({
'--header': [String],

'--aerender-parameter': [String],
'--language': String,

// Aliases
'-v': '--version',
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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'];
Expand Down

0 comments on commit 545282f

Please sign in to comment.