Skip to content

Untranslated keys always return the original value - Breaking change between v11.0.1 & v12.0.0 #1164

@ch-a-bou

Description

@ch-a-bou

Current behavior

In version 12.0.0, the translate directive use the node.originalValue when the key passed is not present in the translation file.
node.originalValue is the first computed value for the text by angular change detection. This test/value can be changed to a completely different value.

Expected behavior

The same behavior as in v11.0.1, the directive should use the current text/value computed by angular change detection

How do you think that we should fix this?

in translate.directive.ts line 88-89
change

// the content was changed from the user, we'll use it as a reference if needed
node.originalContent = node.originalContent || content;

to (it actually makes more sense according to the comment I think)

// the content was changed from the user, we'll use it as a reference if needed
node.originalContent = content || node.originalContent;

Minimal reproduction of the problem with instructions

Have translate directive on a span with a variable. The variable uses some values which are not present in the json translation file. Dynamically change the variable value.

Environment

ngx-translate version: 12.0.0
Angular version: 8.2.14

Browser:

  • Chrome (desktop) version 73

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