Use https://github.com/NodeBB/nodebb-plugin-category-optin but beware if you have thousands of categories and millions of users this plugin will create a lot of entries in the database.
How put a default text in a HTML component with javascript
-
Suppose to have the default text that it is the value of:
[[user:bookmarks]]
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> <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?
-
You need to use the translator module to translate the string.
require(['translator'], function (translator) { translator.translate('[[user:bookmarks]]', function (translated) { //use translated string }); });