angular / angular/angular-cli

[i18n] ability to dynamically load translations for the app

未關閉
#18,331 8 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
area: @angular-devkit/build-angular devkit/build-angular:i18n needs: investigation
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

# 🐞 bug report

### Affected Package
@angular/localize

### Is this a regression?
Yes, it's a regression from v8

### Description
In v8 was a very handy solution to load your translation data for development.
It's described on this documentation page https://v8.angular.io/guide/i18n#merge-with-the-jit-compiler

With the migration to v9 there's no corresponding solution that will allow to quickly switch locales during runtime for development. As far as I understand, the suggested replacement is to run `ng serve` with the desired locale every time.

A little bit background here. We have 2 applications, every with 4 languages. For production, we build it with AOT as suggested. For development we use JIT and load corresponding translation depending on the browser URL (German for `/de/` for example), this mimics prod behavior. So, to switch translation and check how the interface looks in a different language, you just need to pick up another item in the language menu. The page reloads at the same URL but with a different language. Starting from v9 it's not supported, so we would have to run `ng serve` every time for a new language and start from the home page for every language again.

What would be a suggested way repeat v8 behavior? I checked `loadTranslatios` but it accepts a key-value object, not a XLIFF data. Is any function that can transform from XLIFF to a format understandable for `loadTranslations`

## 🌍 Your Environment

**Angular Version:**



Angular CLI: 9.1.9
Node: 12.4.0
OS: darwin x64

Angular: 9.1.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package Version
------------------------------------------------------------
@angular-devkit/architect 0.901.9
@angular-devkit/build-angular 0.901.9
@angular-devkit/build-ng-packagr 0.901.9
@angular-devkit/build-optimizer 0.901.9
@angular-devkit/build-webpack 0.901.9
@angular-devkit/core 9.1.9
@angular-devkit/schematics 9.1.9
@angular/cdk 9.2.4
@angular/cli 9.1.9
@angular/material 9.2.4
@angular/material-moment-adapter 9.2.4
@ngtools/webpack 9.1.9
@schematics/angular 9.1.9
@schematics/update 0.901.9
ng-packagr 9.1.5
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0

貢獻指南

開啟貢獻指南

研究方向

從 @angular/localize 和連結的 v8 JIT i18n 文件開始;將 v9 loadTranslations API 與所要求的 XLIFF 和 runtime-locale 工作流程進行比較。當存在一種受支援的、可在開發期間切換 locale 的方法,並且包括如何處理 XLIFF 資料時,即表示完成。

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

評估

技術堆疊
angular, typescript
領域
localization
Issue 類型
缺陷
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

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

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