This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************************************************************** | |
* 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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ourProyectNameGoesHere-server", | |
"version": "1.0.0", | |
"private": true, | |
"description": "", | |
"keywords": [], | |
"author": "Juan García Carmona", | |
"license": "MIT", | |
"dependencies": { | |
"express": "^4.17.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ourProyectNameGoesHere", | |
"version": "0.1.0", | |
"scripts": { | |
"ng": "ng", | |
"build": "ng build", | |
"start": "ng serve --aot", | |
"lint": "ng lint ourProyectNameGoesHere", | |
"test": "ng test", | |
"e2e": "ng e2e", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | |
"version": 1, | |
"newProjectRoot": "projects", | |
"projects": { | |
"ourProyectNameGoesHere": { | |
"i18n": { | |
"sourceLocale": "en-US", | |
"locales": { | |
"es": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |