# Cannot get translation in .html file

**URL:** https://discourse.nodered.org/t/cannot-get-translation-in-html-file/31628
**Category:** Developing Nodes
**Created:** [16 August 2020 22:07 UTC](https://discourse.nodered.org/t/cannot-get-translation-in-html-file/31628 "2020-08-16T22:07:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [16 August 2020 22:07 UTC](https://discourse.nodered.org/t/cannot-get-translation-in-html-file/31628/1 "2020-08-16T22:07:03Z")

</div>

Hi all, I am working through a node I maintain and adding i18n to the html and JS

#### So far, I have ...

- replacing static text with spans - ✅
  - `<span data-i18n="mssql.node.label.connection">`

- replacing titles and placeholders - ✅
  - ` <input data-i18n="[placeholder]mssql.node.label.name"> </input>`
  - `<div data-i18n="[placeholder]mssql.node.label.name"> </div>`

- Accessing translations in html script - ❌
  - `RED._("mssql.common.query")`_ **not working** _

#### `/src/mssql.html`...

```auto
         var modeField = $("#node-input-modeOpt").typedInput(
                {
                    types:[
                        { value:"query", label: RED._("mssql.common.query"), hasValue:false },
                        { value:"execute", label: RED._("mssql.common.execute_procedure"), hasValue:false },
                        'msg', 'flow', 'global', 'env'            
                    ],
                    typeField: $("#node-input-modeOptType"),
                    default:"query"
                });

```

#### `/src/en-US/mssql.json`...

```auto
{
    "mssql": {
        "common": {
            "editor": "Editor",
            "query": "Query",
            "execute_procedure": "Execute Procedure"            
        },
   ...
   ...

```

I get this (first two items in the dropdown should be "Query" and "Execute Query" - instead, they are the path to the i18n value)...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca0bc64728c4f7209d4b71dcaedb435cfd761863.png)

#### File layout...

- src
  - locales
    - en-US
      - mssql.json

    - mssql.html
    - mssql.js

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [16 August 2020 22:19 UTC](https://discourse.nodered.org/t/cannot-get-translation-in-html-file/31628/2 "2020-08-16T22:19:40Z")

</div>

False alarm - I have solved it - i missed it at the bottom of [this page](https://nodered.org/docs/creating-nodes/i18n)...

> As well as the `data-i18n` attribute for html elements, all node definition functions (for example, `oneditprepare` ) can use `this._()` to retrieve messages.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [30 August 2020 22:19 UTC](https://discourse.nodered.org/t/cannot-get-translation-in-html-file/31628/3 "2020-08-30T22:19:40Z")

</div>

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