了解节点 RED 中的 this._(STRING) 调用
Understanding a this._(STRING) call in node RED
我正在尝试理解 node-red 中 Switch 节点的现有代码,以正确处理和制作我自己的节点。
我受困于这些行:
var operators = [
{v:"eq",t:"=="},
{v:"neq",t:"!="},
{v:"lt",t:"<"},
{v:"lte",t:"<="},
{v:"gt",t:">"},
{v:"gte",t:">="},
{v:"btwn",t:this._("switch.rules.btwn")},
{v:"cont",t:this._("switch.rules.cont")},
{v:"regex",t:this._("switch.rules.regex")},
{v:"true",t:this._("switch.rules.true")},
{v:"false",t:this._("switch.rules.false")},
{v:"null",t:this._("switch.rules.null")},
{v:"nnull",t:this._("switch.rules.nnull")},
{v:"else",t:this._("switch.rules.else")}
];
尤其是this._("switch.rules.smthg")
。它将如何运作?有时在代码中,我会看到这个调用,但我找不到它存储在哪里,所以我自己做,比如 this._(myawesomenode.myawesomesection.myawesomepropertie)
编辑
感谢您的评论,我看到它是为了国际化。
假设我有这个目录:
{
"and": {
"list": {
"key": "THE DATA I WANT"
}
}
}
我怎样才能得到我的数据?我试过 this._(and.list.key)
之类的东西但没有结果。
这是拉入标签翻译版本的功能。
"switch.rules.btwn"
是为用户查找正确语言的标签版本的关键。
有关详细信息,请参阅 Node-RED 文档的 Internationalisation 部分。
我不知道 node-red,但这看起来像是在 this
对象上用 name/identifier _
定义了一些方法,它是用字符串调用的参数.
你可以这样做 this._ = function (arg) {...}
您可能会在 this 对象的构造函数中找到定义(无论在该上下文中是什么)
我正在尝试理解 node-red 中 Switch 节点的现有代码,以正确处理和制作我自己的节点。
我受困于这些行:
var operators = [
{v:"eq",t:"=="},
{v:"neq",t:"!="},
{v:"lt",t:"<"},
{v:"lte",t:"<="},
{v:"gt",t:">"},
{v:"gte",t:">="},
{v:"btwn",t:this._("switch.rules.btwn")},
{v:"cont",t:this._("switch.rules.cont")},
{v:"regex",t:this._("switch.rules.regex")},
{v:"true",t:this._("switch.rules.true")},
{v:"false",t:this._("switch.rules.false")},
{v:"null",t:this._("switch.rules.null")},
{v:"nnull",t:this._("switch.rules.nnull")},
{v:"else",t:this._("switch.rules.else")}
];
尤其是this._("switch.rules.smthg")
。它将如何运作?有时在代码中,我会看到这个调用,但我找不到它存储在哪里,所以我自己做,比如 this._(myawesomenode.myawesomesection.myawesomepropertie)
编辑
感谢您的评论,我看到它是为了国际化。
假设我有这个目录:
{
"and": {
"list": {
"key": "THE DATA I WANT"
}
}
}
我怎样才能得到我的数据?我试过 this._(and.list.key)
之类的东西但没有结果。
这是拉入标签翻译版本的功能。
"switch.rules.btwn"
是为用户查找正确语言的标签版本的关键。
有关详细信息,请参阅 Node-RED 文档的 Internationalisation 部分。
我不知道 node-red,但这看起来像是在 this
对象上用 name/identifier _
定义了一些方法,它是用字符串调用的参数.
你可以这样做 this._ = function (arg) {...}
您可能会在 this 对象的构造函数中找到定义(无论在该上下文中是什么)