This is a fork from: https://github.com/mzuccaroli/universal-multisite-multilanguage
This repo demonstrates the use of Angular Universal Server-side Rendering applied to a multilanguage and multisite application Starting from a simple application codebase it automatically generates two parallel sites with differents assets and contens and translated version of them using i18n and xliffmerge. The express server is configured to serve each site in a different port (4002 and 4001)
The different usage of images are handled differently in universal. Images in templates are hashed and used only by the client app, the server has no access to this hashed images and doesn't find them. Only when the client app takes over, the images are rendered. Disabling hashing makes it possible for the server to access the correct image.
A minimal Angular starter for Universal JavaScript using the Angular CLI If you're looking for the Angular Universal repo go to angular/universal
This demo is built following the Angular CLI Wiki guide
We're utilizing packages from the Angular Universal @nguniversal repo, such as ng-module-map-ngfactory-loader to enable Lazy Loading.
This repo demonstrates the use of Server-side Rendering.
Server-side Rendering (SSR)
- Happens at runtime
- Uses
ngExpressEngine
to render your application on the fly at the requested url.
npm install
oryarn
- run
npm run start:site1
which will startng serve
for site 1 configuration - run
npm run start:site2
which will startng serve
for site 2 configuration
npm run build:ssr && npm run serve:ssr
- Compiles your application and spins up a Node Express to serve your Universal application:
- the site 1 wil be served on
http://localhost:4002
- the site 2 wil be served on
http://localhost:4001
npm run extract-i18n
- extract all the i18n ready to translate strings and put its into to messages.xlf files located in src/locale
After a succesfull production build language specific static versions of the application will be placed in dist/site1/en
dist/site1/it
ecc..
The site 1 translated application will be served on : http://localhost:4002/en
http://localhost:4002/it
http://localhost:4002/fr
The site 2 translated application will be served on : http://localhost:4001/en
http://localhost:4001/it
http://localhost:4001/fr