question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-agius4commented, Dec 28, 2018

Yeah, with the new renderer the translations will be applied at runtime.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`LOCALE_ID` is always `en-US` during server side renderring ...
LOCALE_ID is always en-US during server side renderring. But if we run the same prodution build in browser, LOCALE_ID is correct as expect....
Read more >
Inconsistent behavior of toLocaleString() in different browser
To achieve this, I am using JavaScript method toLocaleString() . This only works fine in Chrome, in other browser it works inconsistently. For...
Read more >
Server-side rendering - Apollo GraphQL Docs
Server -side rendering (SSR) is a performance optimization for modern web apps. It enables you to render your app's initial state to raw...
Read more >
Localized Server-Side Rendering with React | Phrase
Our Express server builds our React app and renders it to a string. Instead of using a <BrowserRouter> , which wouldn't work on...
Read more >
Server-side rendering (SSR) with Angular Universal
This guide describes Angular Universal, a technology that renders Angular applications on the server. A normal Angular application executes in the browser, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found