angular / angular/angular-cli

Ability to manually specify locale in SSR

Open
#29,019 6 comments 5 reactions 0 assignees View on GitHub
area: @angular/ssr feature feature: insufficient votes
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
14h 23m
Merged PRs (30d)
162

Description

### Description

There is no way to specify locale in [`AngularAppEngine#handle`](https://github.com/angular/angular-cli/blob/19.0.0/packages/angular/ssr/src/app-engine.ts#L65-L69) based on [`Accept-Language`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language), [`Cookie`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie), etc. The current implementation of [`AngularAppEngine`](https://github.com/angular/angular-cli/blob/19.0.0/packages/angular/ssr/src/app-engine.ts#L24) chooses locale based on URL.

### Describe the solution you'd like

Ability to specify an array of locales when calling `handle`:

```diff
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 ``.

### Describe alternatives you've considered

_No response_

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.