title: How to translate all objects from it's data attribute?
body: <p>I get some data from an api, then from that data i build my items in DOM, each item has a description which is get in different languages from the API.</p>
  <p>I have a variable which is set with the current choosen language like <code>it, de, en etc...</code></p>
  <p>the object has the folliwing structure:</p>
  <pre><code>{ id: &quot;001&quot;, desc: { it: &quot;Ciao&quot;, en: &quot;Hello&quot;, fr: &quot;Hellous&quot;, de: &quot;Hei&quot;, es: &quot;Hola&quot;, ru: &quot;Привет&quot; }
  </code></pre>
  <p>Then when i create my DOM object i set a data attribute like <code>data-trans-api</code> where i set the whole <code>desc</code></p>
  <p>So my object looks like this:</p>
  <pre><code>  $(&quot;&lt;a&gt;&quot;, {
      class: &quot;flex-sm-fill text-sm-center nav-link&quot;,
    })
      .attr(&quot;data-toggle&quot;, &quot;pill&quot;)
      .attr(&quot;href&quot;, `#tab_${menu.id}`) //added text
      .attr(&quot;aria-controls&quot;, &quot;tab_&quot; + menu.id) //added text
      .attr(&quot;role&quot;, &quot;tab&quot;)
      .data(&quot;trans-api&quot;, menu.desc)
      .attr(&quot;aria-selected&quot;, &quot;false&quot;)
      .text(menu.desc[lang])
  </code></pre>
  <p>Then i have a function which yet translate all static content from my array of languages which looks like this:</p>
  <pre><code>function changeLanguage(language) {
    lang = language;
    $(&quot;[data-trans]&quot;).each(function () {
      let text = $(this).data(&quot;trans&quot;);
      if (text === &quot;articoli&quot;) {
        var qtaProdotti = $(&quot;.prodotto&quot;).length;
        $(&quot;#countProdotti&quot;).text(
          qtaProdotti === 1
            ? qtaProdotti + &quot; &quot; + arrLang[language][&quot;articolo&quot;]
            : qtaProdotti + &quot; &quot; + arrLang[language][&quot;articoli&quot;]
        );
      } else {
        $(this).html([arrLang[language][text]]);
      }
    });
  }
  </code></pre>
  <p>How can i add to it even the translation of the objects created from the API?</p>