question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yarn xliffmerge argument parser broken

See original GitHub issue

using your latest version from today:

My Environment:

  • ubuntu 19.04
  • node 12.4
  • angular 8.0.0.1
  • yarn 1.16.0 and 1.17.0
  • ngx-i18nsupport: 1.1.6

yarn xliffmerge fails to run, it seems to get an extra parameter which it interprets as a language this paramer is the path of xliffmerge (i redacted the paths a little bit)

yarn  xliffmerge -p xliffmerge.json -v en 
 xliffmerge -p xliffmerge.json -v en 
* xliffmerge version 1.1.6
* xliffmerge Used Parameters:
* usedProfilePath:	"xliffmerge.json"
* defaultLanguage:	"en"
* srcDir:	"src/locale"
* genDir:	"src/locale"
* i18nBaseFile:	"messages"
* i18nFile:	"src/locale/messages.xlf"
* languages:	/home/XYZ/src/node_modules/.bin/xliffmerge,en,de,fr,it
* outputFile[/home/XYZ/src//node_modules/.bin/xliffmerge]:	src/locale/messages./homeXYZ/src/node_modules/.bin/xliffmerge.xlf
* outputFile[en]:	src/locale/messages.en.xlf
* outputFile[de]:	src/locale/messages.de.xlf
* outputFile[fr]:	src/locale/messages.fr.xlf
* outputFile[it]:	src/locale/messages.it.xlf
* removeUnusedIds:	true
* supportNgxTranslate:	false
* useSourceAsTarget:	true
* targetPraefix:	""
* targetSuffix:	""
* allowIdChange:	true
* beautifyOutput:	false
* preserveOrder:	true
* autotranslate:	false
ERROR: language "/home/XYZ/src/node_modules/.bin/xliffmerge" is not valid
error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

in your file xliff-merge.js where the command line arguments are parsed

 static parseArgs(argv) {
        const options = {
            languages: []
        };
        for (let i = 1; i < argv.length; i++) {
const arg = argv[i];

its starting from 1, From what I read here: (found in the internet 😉)

// print process.argv
process.argv.forEach(function (val, index, array) {
  console.log(index + ': ' + val);
});
This will generate:

$ node process-2.js one two=three four
0: node
1: /Users/mjr/work/node/process-2.js
2: one
3: two=th

the “real” arguments also should start from 2 not 1.

So if i change line 53 to for (let i = 2; i < argv.length; i++) {

it works for me.

As an alternative: addind to the parseArgs something like

else if (arg.length > 0 && arg.charAt(0) === '/') {
                console.log('ignore this');
            }

works too, but i guess thats not generic enough.

Not sure whether this is specific to using yarn or my setup.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
hansmaadcommented, Mar 17, 2021

As a workaround for Angular 10+, I created a small script to directly call the xliffmerge function

const xliffmerge = require('@ngx-i18nsupport/ngx-i18nsupport/src/xliffmerge/xliff-merge');
xliffmerge.XliffMerge.main([process.argv[0], ...process.argv.slice(2)]);

I call it from package.json

"xi18n:merge": "node xliffmerge.js --profile xliffmerge.json en de"
4reactions
MarcusRiemercommented, Jan 21, 2021

This issue is still present, I can only run xliffmerge from the commandline when discarding the first argument. Otherwise the path to the xliffmerge “binary” entry file is mistaken as a language.

Is there any chance of a hotfix specifically for xliffmerge? I do understand that keeping up with Angulars Builder API is an invidious task, but this neat little tool works quite fine on its own.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bountysource
yarn xliffmerge argument parser broken.
Read more >
xliffmerge with angular what does profile.json contain
My configuration file (xliffmerge.json) is in the same folder as package.json ... "extract-i18n": "ng xi18n --output-path i18n && xliffmerge ...
Read more >
@peertube/xliffmerge - npm
Merge XLIFF used by PeerTube. Latest version: 2.0.3, last published: a year ago. Start using @peertube/xliffmerge in your project by running ...
Read more >
Front-end - personeltest.ru
$this->_twigEnvironment->render( $template, $args );} catch ( Exception $ex ) ... will generate ean exception if a template doesn't exist OR broken // also...
Read more >
Martin Roob ngx-i18nsupport Issues - Giters
yarn xliffmerge argument parser broken ... xliffmerge: use official Angular v9 i18n config ... Arabic auto translate problem with xliffmerge.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found