Skip to content

Translator can't substitute empty strings #2389

Description

@MikeBishop

Platform: Raspberry Pi 4

Node Version: 10.23.0

MagicMirror Version: 2.13.0

Description: In translator.js, the code checks whether a variable is present with the following code:

return variables[varName] || "{" + varName + "}";

However, when the content of the variable is an empty string, this erroneously substitutes {varName} back in.

Steps to Reproduce: Call this.translate("something with {VAR}", {VAR: ""})

Expected Results: If the variable is present with the empty string, the empty string should be substituted. This could be achieved by using return varName in variables ? variables[varName] : "{" + varName + "}"; instead.

Actual Results: Variable is not subsituted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions