Transloco: Feature request: component level scope alias

Created on 25 Sep 2019  路  3Comments  路  Source: ngneat/transloco

I'm submitting a...


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

Current behavior

Currently in order to specify alias for component scope translations you have to do it in main APP module's TRANSLOCO_CONFIG object. This means that every time you add or remove component with it's own scope, you have to keep in mind that you have to update another file, which has nothing to do with component itself.

Expected behavior

What I propose, is to be able to define scope alias on component level. We think it will make the whole process much easier and will avoid repetitions in the code.

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

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

Right now we keep translation files in the same folder with components, each component has its own translation files - to keep components as self contained as possible. So it would be much easier to specify scope alias within component itself rather than going to APP module every time you create/remove a component.

And in general we think it will be much easier, not only in our case.

I've implemented the test version of this feature which is backwards compatible.
Please have a look at: https://github.com/zufarzhan/transloco/tree/feat/scope-alias

Let me know what you think about this feature, and maybe I should finish it and make a PR?

P.S. Another thing I noticed: when you specify scope on module level, then specify scope on component level which is part of the module, you get error if you try using translations from module scope level. So maybe it's better to mention it in the doc or maybe handle it somehow in the code?

Environment


Angular version: 7.2.0


Browser:
- [x] Chrome (desktop) version 76
- [ ] 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: 10.16.1  
- Platform:  MacOS 10.14.6 

Others:




PRs welcome enhancement

Most helpful comment

Added in #100 published in v2.1.0, @zufarzhan thanks 馃帀

All 3 comments

@zufarzhan Would you like to open a PR for it?

@shaharkazaz sure, will do it a bit later :)

Added in #100 published in v2.1.0, @zufarzhan thanks 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KrisHaney picture KrisHaney  路  5Comments

philjones88 picture philjones88  路  6Comments

nulee picture nulee  路  6Comments

frct1 picture frct1  路  3Comments

mickz18 picture mickz18  路  3Comments