若你以 --localize 選項執行 ng build 指令,Angular CLI 會自動包含地區設定資料。
ng build --localize
HELPFUL: Angular 初始安裝時已包含美式英文 (en-US) 的地區設定資料。
當你搭配 ng build 指令使用 --localize 選項時,Angular CLI 會自動包含地區設定資料並設定 LOCALE_ID 的值。
npm 上的 @angular/common 套件包含地區設定資料檔案。
地區設定資料的全域變體位於 @angular/common/locales/global。
法文的 import 範例
例如,你可以在啟動應用程式的 main.ts 中,匯入法文 (fr) 的全域變體。
src/main.ts (匯入地區設定)
import '@angular/common/locales/global/fr';
HELPFUL: 在 NgModules 應用程式中,你要在 app.module 中匯入它。