GithubHelp home page GithubHelp logo

Comments (4)

Romanchuk avatar Romanchuk commented on June 30, 2024

Yes, it is possible to use angular-i18next with Universal and SSR.
There is no specific angular-i18next settings to use it with SSR.

Just use official i18next plugin for SSR:

https://github.com/i18next/i18next-http-middleware

And load you translations from filesystem on node.js backend:

https://www.i18next.com/overview/plugins-and-utils#backends

Demo app implements SSR:

https://github.com/Romanchuk/angular-i18next/tree/master/apps/angular-i18next-demo

I have no time at the moment to make good doc about SSR

from angular-i18next.

michal-seidler avatar michal-seidler commented on June 30, 2024

Thank you now it's working but I have another issue when I try to prerender I got the:
No provider for InjectionToken REQUEST do you have some advice?

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 30, 2024

@michal-seidler Sorry for waiting:

import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { REQUEST } from '@nguniversal/express-engine/tokens';
import { I18NEXT_INSTANCE } from 'angular-i18next';
import type { Request } from 'express';
import { I18NextRequest } from 'i18next-http-middleware';

import { AppComponent } from './app.component';
import { AppModule } from './app.module';


@NgModule({
  imports: [
    AppModule,
    ServerModule,
  ],
  bootstrap: [AppComponent],
  providers: [
    {
      provide: I18NEXT_INSTANCE,
      useFactory: (req: Request & I18NextRequest) => {
          return req.i18n;
      },
      deps: [
        REQUEST
      ]
    }
  ]
})
export class AppServerModule {}

from angular-i18next.

Romanchuk avatar Romanchuk commented on June 30, 2024

Closed due inactivity

from angular-i18next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.