vendure-ecommerce / ngx-translate-extract

Extract translatable (using ngx-translate) strings and save as a JSON or Gettext pot file
MIT License
51 stars 19 forks source link

8.2.0 extract breaks with --null-as-default-value #18

Closed emmaengl closed 1 year ago

emmaengl commented 1 year ago

Since updating to 8.2.0 the ngx-translate-extract command fails with following error when using the --null-as-default-value flag:

An error occurred: TypeError: Cannot read properties of null (reading 'value')

No issues with parsing pre-existing keys, only on adding new ones. The issue persists on 8.2.1, my guess is that it's related to the type checking introduced in 8.2.0. Can someone take a look? 🙏

Wradgio commented 1 year ago

I have the same issue. Created a new project with only one file as a source of translation strings. Running ngx-translate-extract --input ./projects/xxx --output ./projects/xxx/i18n/{de,fr}.json --sort --clean --format 'namespaced-json' -n --format-indentation ' '" returns:

An error occurred: TypeError: Cannot read properties of null (reading 'value')

It works after running without -n resp. --null-as-default-value flag, but of course, strings are empty by default.

michaelbromley commented 1 year ago

Hi, thanks for the report. Can you confirm that the last working version was?

emmaengl commented 1 year ago

@michaelbromley for us it was 8.1.1

michaelbromley commented 1 year ago

Paging @SamanthaAdrichem - off the top of your head can you think of anything in your work that might have affected this --null-as-default-value flag?

SamanthaAdrichem commented 1 year ago

No, but its most likely caused by not creating the new interface on the default null values but just null.

it's probably something like

    key: null

instead of the new

   key: <NewInterface>{value: null, sources: []}

(didn't look at the code, done this from memory so will have many typo's)

I'll push a fix this afternoon

SamanthaAdrichem commented 1 year ago

See PR :)

If someone could test it as well, that would be lovely

Just clone the pull request,

git clone git@github.com:SamanthaAdrichem/ngx-translate-extract.git ./ngx-translate-extract
cd ngx-translate-extract
git checkout issue-18

Then run build

npm run build

and then run your script with node for example (assuming you put the folder next to your project folder like so)

.
..
ngx-translate-extract/
your-project/

run it as you always do, just replace the path with

node ../ngx-translate-extract/dist/cli/cli.js YOUR_ARGUMENTS
emmaengl commented 1 year ago

@SamanthaAdrichem , thanks for getting to this so quickly, can confirm it works for me 🎉

michaelbromley commented 1 year ago

Thanks all for your quick attention! I just released v8.2.2 which contains this fix 👍