robisim74 / angular-l10n

Angular library to translate texts, dates and numbers
MIT License
380 stars 59 forks source link

Angular universal #306

Closed ihor-zinchenko closed 4 years ago

ihor-zinchenko commented 4 years ago

Hi! I'm using angular universal and it build HTML for my app but before translations loading I see

'some.title.or.something.else'

How I can load translations immediately and after that build HTML?

Or for angular universal I should use another way to connect translations?

robisim74 commented 4 years ago

Hi,

For the previous version of the library, I wrote a simple guide: https://github.com/robisim74/angular-l10n/blob/angular_v8/docs/quick-start.md#server-side-rendering-ssr

ihor-zinchenko commented 4 years ago

@robisim74

  1. I using the latest version
  2. Yep
    {
      provide: APP_INITIALIZER,
      useFactory: initL10n,
      deps: [L10nLoader],
      multi: true
    },
  3. No, but I'm solve my issue by moving from JSON to .ts files

But now I have a new problem. The server always returns only first language for the user, if I go to example.com/en, I've got English version, but if I go to example.com/ru after that, I've got English version to

I'll try your example maybe it's fixing my issue, thx!

ihor-zinchenko commented 4 years ago

Solved by using cookie on the server and client