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

Default values show for few seconds in content in slow networks. #22

Open
nktkarnany opened this issue Aug 24, 2018 · 1 comment
Open

Comments

@nktkarnany
Copy link

Bug Report or Feature Request (mark with an x)

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

OS and Version?

Mac - High Sierra

Versions

Angular CLI: 1.7.4
Node: 8.9.4
Angular: 4.4.7

Repro steps

1.  Change the default text in the content.
2. Change network speed to 3g from chrome networks tab.
3. Reload the page and the cookie consent default value is shown for few seconds before the translation changes appear
4. How I fixed this is with a simple hack - 
* In AppModule config for cookie consent, I used autoOpen: false
* In AppComponent ngOnInit method I used this - 
    this.translate.get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link']).subscribe(data => {

        this.ccService.getConfig().content = this.ccService.getConfig().content || {} ;
        // Override default messages with the translated ones
        this.ccService.getConfig().content.header = data['cookie.header'];
        this.ccService.getConfig().content.message = data['cookie.message'];
        this.ccService.getConfig().content.dismiss = data['cookie.dismiss'];
        this.ccService.getConfig().content.allow = data['cookie.allow'];
        this.ccService.getConfig().content.deny = data['cookie.deny'];
        this.ccService.getConfig().content.link = data['cookie.link'];

        this.ccService.init(this.ccService.getConfig());
        if (!this.ccService.hasConsented())
          this.ccService.open();
        else
          this.ccService.destroy();
      });

The log given by the failure

Desired functionality

The cookie consent should show the custom content only but not the default values. This leads to bad experience for slow networks.

Mention any other details that might be useful

@tinesoft
Copy link
Owner

Hi @nktkarnany

Thanks for reporting this.
I will update the README.md section about i18n to mention your hack, which is, to me, the best way to address the issue (due to async nature of translation mechanism).

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

2 participants