Skip to content

Instantly share code, notes, and snippets.

Avatar

Joldibaev Nurlan joldibaev

View GitHub Profile
View language-interceptor.ts
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Inject, Injectable, LOCALE_ID } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable()
export class LanguageInterceptor implements HttpInterceptor {
currentLocale: string;
constructor(@Inject(LOCALE_ID) public locale: string) {
this.currentLocale = this.locale.split('-', 1)[0];
View proxy-server.js
const express = require("express");
const path = require("path");
const getTranslatedServer = (lang) => {
const targetServerPath = path.join(
process.cwd(),
`ourProyectNameGoesHere/server/${lang}`
);
const server = require(`${targetServerPath}/main.js`);
return server.app(lang);
View server.ts
/***************************************************************************************************
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
*/
import { APP_BASE_HREF } from '@angular/common';
import { LOCALE_ID } from '@angular/core';
import '@angular/localize/init';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { existsSync } from 'fs';
import { join } from 'path';