biesbjerg / ngx-translate-extract

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

Array value erased when extract #244

Open lufo88ita opened 2 years ago

lufo88ita commented 2 years ago

Hi,

First of all: thanks for your work. It is a hge help in manage the translations. My problem: Maybe I do not understand something but array values in .json files is erased when I run your library. This is how I call ngx-translate-extract:

ngx-translate-extract -f namespaced-json -i ./src/**/*.{ts,html} -o ./src/assets/i18n/messages.{de,en,es,fr,it,zh-Hans}.json -s -n -c

All works great and as I want, except one thing: if the value provided in a translations in an array it will be erased.

I search a bit and try to remove some parameter, in the end I discover that the array is split. Example. In my messages.en.json I wrote this entry:

{
//others translations
"dayNamesMin" : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
}

I run the script above without the -c parameter. The final messages.en.json is this:

{
//others translations
"dayNamesMin" : null
"dayNamesMin.0" : "Su"
"dayNamesMin.1" : "Mo"
"dayNamesMin.2" : "Tu"
"dayNamesMin.3" :  "We"
"dayNamesMin.4" : "Th"
"dayNamesMin.5" : "Fr"
"dayNamesMin.6" : "Sa"
}

Of course, if the -c is present the dayNamesMin. will be all deleted

What is my error? the array is a valid json type and Ngx-translate support it.