jsverse / transloco

πŸš€ 😍 The internationalization (i18n) library for Angular
https://jsverse.github.io/transloco/
MIT License
2.01k stars 195 forks source link

Schematics : Ng-add translate-type option 'Typescript' deprecated #279

Closed pedraldo closed 4 years ago

pedraldo commented 4 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[X] Documentation issue or request
[ ] Support request
[X] Other... Please describe: Questions

Current behavior

We can read in schematics documentation that it's possible to set the --translate-type option to 'Typescript'.
I was telling me that Typescript files instead of "classic" JSON files could be interesting so I tried to launch ng add @ngneat/transloco --translate-type Typescript.
Unfortunately, I discovered that JSON files was generated instead of ts files.
I tried to launch the same command with quotes (ng add @ngneat/transloco --translate-type 'Typescript') but the result is the same.

Expected behavior

I was expecting that the --translate-type option of ng add schematic command generates .ts translation files instead of .json.

Minimal reproduction of the problem with instructions

For bug reports please provide the STEPS TO REPRODUCE and if possible a MINIMAL DEMO of the problem, for that you could use our stackblitz example

On a standard Angular project (testable with a fresh new project), install transloco (with npm for example) and launch :
ng add @ngneat/transloco --translate-type Typescript

What is the motivation / use case for changing the behavior?

I wondered why this option doesn't seem to work.
I found that actually the --translate-type option is no longer useful because .json files will be generated in all cases.

Generating .ts files was possible in the past, but this commit on the schematics/src/ng-add/index.ts file changed the game.

Knowing all of this, I have few questions :

Once again, I think that .tstranslation file could be interesting.
It could allow us to break line and indent translations. I'm actually thinking about complex ICU / MessageFormat translation that we must write in a single line inside a JSON file, and sometime a line can be veeeeeery long πŸ˜‰. By the way if someone has a solution to this specific "problem" I'm interested !

Environment


Angular version: 9.1.2
Transloco version : 2.17.0


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: 12.16.1
- Platform:  Mac

Others:

I can share more packages and other configurations that I used but I don't think that it is necessary in that case. If needed I'll do it for sure !
Thank you in advance for your answers.
Cheers

itayod commented 4 years ago

Hi @pedraldo I have updated the docs accordingly, though using typescript for your translation files format is possible, it is not the standard way and might create some problems in certain cases.