Angular $localize 不是一个函数

Rea*_*rld 3 internationalization angular-i18n angular

我尝试$localize在我的 ts 文件中使用时遇到一个奇怪的错误。我收到这个错误

Error: Uncaught (in promise): TypeError: _angular_localize_init__WEBPACK_IMPORTED_MODULE_3__.$localize is not a function
TypeError: _angular_localize_init__WEBPACK_IMPORTED_MODULE_3__.$localize is not a function
Run Code Online (Sandbox Code Playgroud)

我的模板文件中有本地化工作,并且调用时没有错误ng build$localize该错误发生在运行时调用包含该方法的组件时。我的ts代码是

  private handleServerErrors(error: HttpErrorResponse): void {
    // Handle errors
    this.complete = true;
    switch (error.status) {

      ...

      case 500:
      default:
        // Could not update user
        this.errorMessage = $localize`:@@CalmBreathing_Desc_Short:Cobblers`;
        break;
    }
    console.error(error);
  }
Run Code Online (Sandbox Code Playgroud)

polyfills.ts 文件的顶部有此内容

/***************************************************************************************************
 * Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
 */
import '@angular/localize/init';
Run Code Online (Sandbox Code Playgroud)

这是带有 Nodejs 12 的 Angular 11.2.8。有什么想法吗?

Rea*_*rld 18

WebStorm 试图提供帮助。它将以下行添加到我的 ts 文件的顶部

import { $localize } from '@angular/localize/init';
Run Code Online (Sandbox Code Playgroud)

这导致它无法工作