Divec has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/336957 )
Change subject: Update bin/apertium-xhtml to work with config.yaml ...................................................................... Update bin/apertium-xhtml to work with config.yaml Change-Id: Ie1a586917b7af5943d493bf42d89bf5a3867d1bc --- M bin/apertium-xhtml 1 file changed, 18 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver refs/changes/57/336957/1 diff --git a/bin/apertium-xhtml b/bin/apertium-xhtml index 4d23f06..5f0e33d 100755 --- a/bin/apertium-xhtml +++ b/bin/apertium-xhtml @@ -1,6 +1,21 @@ #!/usr/bin/env node -var sourceLang, targetLang, sourceHtml, script, args, +var sourceLang, targetLang, sourceHtml, script, args, config, cxConfig, + fs = require( 'fs' ), + yaml = require( 'js-yaml' ), Apertium = require( __dirname + '/../mt/Apertium.js' ); + +config = yaml.load( fs.readFileSync( 'config.yaml' ) ); +if ( !config ) { + console.error( 'Failed to load config' ); + process.exit( 1 ); +} +cxConfig = config.services && Array.isArray( config.services ) && config.services.filter( function ( item ) { + return item && item.name === 'cxserver'; +} )[ 0 ]; +if ( !cxConfig ) { + console.error( 'Cannot find cxserver config' ); + process.exit( 1 ); +} script = process.argv[ 1 ]; args = process.argv.slice( 2 ); @@ -22,13 +37,13 @@ sourceHtml.push( data ); } ); process.stdin.on( 'end', function() { - new Apertium().translate( + new Apertium( cxConfig ).translate( sourceLang, targetLang, sourceHtml.join( '' ) ).then( function( targetHtml ) { process.stdout.write( targetHtml + '\n' ); - }, function( error ) { + }).catch( function( error ) { if ( error.stack ) { console.error( 'error', error.stack ); } else { -- To view, visit https://gerrit.wikimedia.org/r/336957 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie1a586917b7af5943d493bf42d89bf5a3867d1bc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: Divec <da...@troi.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits