# How can I get object from RED.\_() function?

**URL:** <https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550>\
**Category:** Developing Nodes\
**Created:** [11 January 2023 16:48 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550 "2023-01-11T16:48:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![studiobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/studiobox/32/55766_2.png) [@studiobox](https://discourse.nodered.org/u/studiobox)\
**Post date:** [11 January 2023 16:48 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/1 "2023-01-11T16:48:24Z")

</div>

Hi,

I use RED.\_("node.myKey") but the result is below.

key 'node.myKey (en-US)' returned an object instead of string.

How can I get object from RED.\_() function? Because I want to get object from "Internationalisation" json file.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 January 2023 20:31 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/2 "2023-01-11T20:31:37Z")

</div>

We do not support returning objects - only string messages.

Can I ask what your use case is for getting an object back?

---

<div class="post-metadata">

**Author:** ![studiobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/studiobox/32/55766_2.png) [@studiobox](https://discourse.nodered.org/u/studiobox)\
**Post date:** [12 January 2023 11:47 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/3 "2023-01-12T11:47:48Z")

</div>

Thank you so much for your reply. 🙂

My use case is using Internationalisation for display group of labels in external client javascript module.

1. I create httpAdmin.get at created-node.js for return Internationalisation string, which I want to use.

2. I create $.getJSON(..) function for get Internationalisation string from above (1).

3. After I got Internationalisation string, I send them to external client javascript module.

No problem, if it is impossible to get object.

At above (1), I maybe read each string intead of once reading object, then create a custom object from reading each string.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 January 2023 15:36 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/4 "2023-01-12T15:36:15Z")

</div>

You should not need to create your own admin end-point; the editor will have loaded your node's message catalogue as well.

---

<div class="post-metadata">

**Author:** ![studiobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/studiobox/32/55766_2.png) [@studiobox](https://discourse.nodered.org/u/studiobox)\
**Post date:** [12 January 2023 16:02 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/5 "2023-01-12T16:02:56Z")

</div>

In my understand, the editor use Internationalisation through i18n in html tag.

I am not sure, is there another method for using Internationalisation through javascript or jQuery in html? Because I want to gather Internationalisation, and send to my external javascript module.

Below are my present code.

1. In my node-line-notify.js, create httpAdmin.get for provide Internationalisation.

```auto
RED.httpAdmin.get('/emojiLabels', function(req, res) {
        res.json({
            "smile-people": RED._("node-line-notify.emoji-group-labels.smile-people"),
            "animal-nature": RED._("node-line-notify.emoji-group-labels.animal-nature"),
            "food-drink": RED._("node-line-notify.emoji-group-labels.food-drink"),
            "activity": RED._("node-line-notify.emoji-group-labels.activity"),
            "travel-places": RED._("node-line-notify.emoji-group-labels.travel-places"),
            "objects": RED._("node-line-notify.emoji-group-labels.objects"),
            "symbols": RED._("node-line-notify.emoji-group-labels.symbols"),
            "flags": RED._("node-line-notify.emoji-group-labels.flags")
        });
    });

```

1. Use external javascript module in node-line-notify.html

```auto
<script src="resources/node-red-contrib-node-line-api/emoji-picker.js"></script>

```

1. Use jQuery "getJSON" call "emojiLables" at above No.1, then send result to my external javascript module.

```auto
<script type="text/javascript">
    (() => {
          ....
          let objEmojiLabel = null;
          $.getJSON('emojiLabels', (data) => {
               console.log("success load emoji labels");
               objEmojiLabel = data;
                  })
                  .fail(function () {
                      console.log("error load emoji labels");
                  })
                  .always(function () {
                      console.log("complete load emoji labels");
                      new EmojiPicker({
                          trigger: [
                              {
                                  selector: '.btnEmoji',
                                  insertInto: '.node-input-message'
                              }
                          ]
                      }, setButtonState, objEmojiLabel);
                  });    
           .....
   }
</script>

```

Please advise me.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [12 January 2023 16:10 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/6 "2023-01-12T16:10:44Z")

</div>

If you are running in the editor, you have `RED._()` function available to you.

You could try it straight away by opening the browser's JavaScript console with Node-RED editor open, then see what the following returns:

```auto
RED._("node-red-contrib-node-line-api/node-line-notify:node-line-notify.emoji-group-labels.smile-people")

```

Note how you have to prefix the message identifier with the catalog name - which is the `module/set` identifier - where `set` is the name of the entry in your `package.json` that points to the node that loads this catalog...

This is based on what I can see in your current github.

---

<div class="post-metadata">

**Author:** ![studiobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/studiobox/32/55766_2.png) [@studiobox](https://discourse.nodered.org/u/studiobox)\
**Post date:** [12 January 2023 16:51 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/7 "2023-01-12T16:51:51Z")

</div>

Thank you very much for your advise. 😊

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 January 2023 16:52 UTC](https://discourse.nodered.org/t/how-can-i-get-object-from-red-function/73550/8 "2023-01-26T16:52:49Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
