1

I'm currently working on an Angular 20 project with Server-Side Rendering and the ngx-translate library.

I've already read through the ngx-translate docs and found this about fixing UI glitches when loading translations, but I'm wondering if anyone has found a better solution than making a loading screen or loading blank text initially using a handler.

I feel like I may be close to a solution using provideAppInitializer in app.config.ts as stated in the Angular docs:

If the function returns a Promise or an Observable, initialization does not complete until the Promise is resolved or the Observable is completed.

We can creating a Promise to wait and resolve translate.use, but the issue is that getBrowserLang() returns undefined on the server, and I get errors in places that call .stream with _().

Does anyone have a solution or do I have to give in with using a loading screen / loading blank text?

2
  • 1
    Returns the browser’s current language setting if available, or undefined if it cannot be determined. Docs, In server side does not have "navigator".language. Before load app, make a request sending current language when you have available navigator. Commented Sep 22 at 20:12
  • 1
    you can check platform before call getBrowserLang and set default language on server side, but u cant know browser language on server... Commented Sep 23 at 8:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.