How put a default text in a HTML component with javascript

  • GNU/Linux

    Suppose to have the default text that it is the value of:


    I want put this text in html component that I create with a function:

    function createElement(pid) {
    return '<a name="pid' + pid + '" role="menuitem" tabindex="-1" href="#" data-favourited="false"><span class="favourite-text">[[user:bookmarks]]</span>&nbsp;<i component="post/bookmark/on" class="fa fa-heart hidden"></i><i component="post/bookmark/off" class="fa fa-heart-o"></i></a>' }

    The problem is when the link appears, the text is "[[user:bookmarks]]" and not the real text that [[user:bookmarks]] refers. Anyone can help me?

  • Admin

    You need to use the translator module to translate the string.

    require(['translator'], function (translator) {
        translator.translate('[[user:bookmarks]]', function (translated) {
              //use translated string



Looks like your connection to NodeBB was lost, please wait while we try to reconnect.