Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct configuration delivery (translations) #14

Closed
magoss opened this issue Jun 1, 2018 · 4 comments
Closed

Correct configuration delivery (translations) #14

magoss opened this issue Jun 1, 2018 · 4 comments

Comments

@magoss
Copy link

magoss commented Jun 1, 2018

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

OS and Version?

Windows 10

Versions

Angular 4.2.4

Desired functionality

I use translation service inside my Angular app. I have a problem with delivery of translations to ngx-cookieconsent configuration. Is there any way to pass configuration object later, inside component? I see it's required to initialize module, but It's odd to pass translation from the module level. I mean:

NgcCookieConsentModule.forRoot(cookieConfig)

I have to have translations already here, but I have it only in a component - they come from a service.

Would be awesome to abstract out messages from configuration object to make it translateable.

@tinesoft
Copy link
Owner

Hi @magoss ,

This would be indeed a great feature. I will start working on it asap.
Quick question: what translation library do you use? ngx-translate?

@magoss
Copy link
Author

magoss commented Jun 11, 2018

Yup, ngx-translate.

@yduartep
Copy link

yduartep commented Jun 12, 2018

This could be a great feature. I have to do something like this to allow translations before to open it...

combineLatest(
    this.translate.get('cookie.content'),
    this.translate.get('cookie.button'),
    this.translate.get('cookie.link')
  ).subscribe(data => {
    this.cookieConfig.content.message = data[0];
    this.cookieConfig.content.dismiss = data[1];
    this.cookieConfig.content.deny = data[2];

    this.ccService.init(this.cookieConfig);
    this.ccService.open();
  });

@tinesoft
Copy link
Owner

Hi guys,

So i finally got time to work on this issue. After deep analysis, i came to the conclusion that there will be no direct support of translation inside the library, not with ngx-translate, nor with any other i18n libraries. Instead, i have updated demo app to showcase how this can be performed (inspired from @yduartep's answer, which is the proper way to do it).

The documentation has been updated as well.

Happy coding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants