Skip to content

Translations with directive with "raw" content of element as a key doesn't work in Angular 9 #1153

@grudus

Description

@grudus

Hi!
I'm trying to add translations to the new Angular9 app, but I've got strange behaviour with translate directive. While all of these work fine:

<div>{{'MENU.INTEGRATION' | translate}}</div>
<div [translate]="'MENU.INTEGRATION'"></div>
<div translate>{{'MENU.INTEGRATION'}}</div>

I cannot get translation for

<div translate>MENU.INTEGRATION</div>

There is no error in the console, as if the translation doesn't work and the raw key is shown.

I'm using @ngx-translate/core: ^11.0.1, and Angular 9.0.0-rc.7
Here is some configuration info:

// package.json
{
  "dependencies": {
    "@angular/animations": "~9.0.0-rc.7",
    "@angular/common": "~9.0.0-rc.7",
    "@angular/compiler": "~9.0.0-rc.7",
    "@angular/core": "~9.0.0-rc.7",
    "@angular/forms": "~9.0.0-rc.7",
    "@angular/platform-browser": "~9.0.0-rc.7",
    "@angular/platform-browser-dynamic": "~9.0.0-rc.7",
    "@ngx-translate/core": "^11.0.1",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.0-rc.7",
    "@angular-devkit/build-ng-packagr": "~0.900.0-rc.7",
    "@angular/cli": "~9.0.0-rc.7",
    "@angular/compiler-cli": "~9.0.0-rc.7",
    "@angular/language-service": "~9.0.0-rc.7",
    "codelyzer": "^5.1.2",
    "ng-packagr": "^9.0.0-rc.3",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.6.4"
  }
}
// tsconfig.json
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "@core/*": ["projects/core/src/lib/*"],
      "components": [
        "dist/components"
      ],
      "components/*": [
        "dist/components/*"
      ]
    },
    "resolveJsonModule": true,
    "esModuleInterop": true
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions