angular / angular/angular-cli

Ability to manually specify locale in SSR

未關閉
#29,019 6 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視
area: @angular/ssr feature feature: insufficient votes
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

### 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_

貢獻指南

開啟貢獻指南

研究方向

從 packages/angular/ssr/src/app-engine.ts 開始,重點查看 AngularAppEngine#handle 及其目前基於 URL 的 locale 選擇。追蹤 locale 如何傳遞到轉譯後的文件中,然後驗證呼叫端可以從請求資料提供一個有序的 locale 陣列,並驗證產生的 不會保留不需要的 locale 前綴。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, typescript
領域
backend, internationalization
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。