Angular PWA / Service worker 离线翻译宽度 ngx-translate

Angular PWA / Service worker offline translation width ngx-translate

我有一个 angular pwa 应用程序使用 @ngx-translate/core and @ngx-translate/http-loader 进行翻译。所以我想知道如果设备处于离线状态,是否有可能让翻译工作。

有没有办法缓存 http-loader 请求,也许在 ngsw-config.json 文件的数据组中?

如果您遵循标准模式并使用 json 文件作为您的语言环境信息,那么您将使用资产组(见下文):

{
  "name": "translate",
  // Use lazy. You don't want to install unless they use the translation
  "installMode": "lazy", 
  // Use prefetch because you want it to update every time the app updates
  "updateMode": "prefetch",
  "resources": {
    "files": "/assets/i18n/*.json"
  }
}

https://christianlydemann.com/how-to-cache-http-requests-in-an-angular-pwa/ and https://angular.io/guide/service-worker-config