Ability to manually specify locale in SSR

Open
#29,019 6 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, typescript

Research direction

Start with packages/angular/ssr/src/app-engine.ts, especially AngularAppEngine#handle and its current URL-based locale selection. Trace how the locale reaches the rendered document, then verify that callers can provide an ordered locale array from request data and that the resulting does not retain an unwanted locale prefix.

Written by the indexing model from the issue text.

Description

area: @angular/ssr feature feature: insufficient votes
Description

There is no way to specify locale in AngularAppEngine#handle based on Accept-Language, Cookie, etc. The current implementation of AngularAppEngine chooses locale based on URL.

Describe the solution you'd like

Ability to specify an array of locales when calling handle:

 app.use('/**', (req, res, next) => {
   angularApp
-    .handle(req)
+    .handle(req, undefined, { locales: req.acceptsLanguages() })
     .then((response) =>
       response ? writeResponseToNodeResponse(response, res) : next(),
     )

As far as I understand, this will also require removing the locale prefix from <base href="…"/>.

Describe alternatives you've considered

No response

Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
16h 35m
Merged PRs (30d)
176

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from angular/angular-cli

All issues in angular/angular-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.