Skip to content

LOCALE_ID is always en-US during server side renderring, and inconsistent with browser build #12075

@clark0x

Description

@clark0x

LOCALE_ID is always en-US during server side renderring. And if we run the same prodution build in browser, LOCALE_ID is correct as expect.

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.1.5
Node: 8.11.2
OS: darwin x64
Angular: 6.1.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.5
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.7.5
@angular/cli                      6.1.5
@ngtools/webpack                  6.1.5
@schematics/angular               0.7.5
@schematics/update                0.7.5
rxjs                              6.3.1
typescript                        2.9.2
webpack                           4.9.2

Repro steps

Checkout https://github.com/clarkorz/angular6-ssr-issue-locale-fix-to-en

$ git clone git@github.com:clarkorz/angular6-ssr-issue-locale-fix-to-en.git
$ cd angular6-ssr-issue-locale-fix-to-en
$ yarn
$ yarn build:i18n-ssr
$ yarn serve:ssr

Access es endpoint, expect LOCALE_ID to be es.

$ curl http://localhost:4000/es/

...
<app-root ng-version="6.1.6"><h1>Hello</h1><p>locale is en-US</p></app-root>
...

If I run the same prodution build in browser, I got es for LOCALE_ID:

$ yarn serve:browser

Open browser to access http://localhost:5000/es/, I got es in browser and LOCALE_ID is es in console.

The log given by the failure

LOCALE_ID is always en-US during server side renderring.

// in another terminal
$ curl http://localhost:4000/es/

// in serve terminal
Node Express server listening on http://localhost:4000
LOCALE_ID is en-US

Desired functionality

LOCALE_ID should be as same as the --i18n-locale parameter of ng build or configuration parameter i18nLocale in angular.json.

LOCALE_ID should be consistent on both server side and browser side.

Mention any other details that might be useful

No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: docsRelated to the documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions