[nodebb-plugin-poll] Poll plugin
-
@julian said:
Ah, it would be up to the individual plugin to use language strings... I'm not entirely sure on the process. @psychobunny ?
Missed this. Have a look here for a sample plugin that uses i8n
EDIT: You'd have to file a PR to make it i8n compatible as well Here is the relevant line in plugin.json, and then of course you just have to move the hardcoded english strings into a
en_GB
folder -
it doesnt work on my forum (latest master)
if i make a poll, it instantly crashes and outputs
11/2 17:37 [24613] - error: TypeError: undefined is not a function
at /home/chas/nbb/nodebb/src/database/redis/list.js:12:4
at try_callback (/home/chas/nbb/nodebb/node_modules/redis/index.js:573:9)
at RedisClient.return_reply (/home/chas/nbb/nodebb/node_modules/redis/index.js:661:13)
at ReplyParser.<anonymous> (/home/chas/nbb/nodebb/node_modules/redis/index.js:309:14)
at ReplyParser.EventEmitter.emit (events.js:95:17)
at ReplyParser.send_reply (/home/chas/nbb/nodebb/node_modules/redis/lib/parser/javascript.js:300:10)
at ReplyParser.execute (/home/chas/nbb/nodebb/node_modules/redis/lib/parser/javascript.js:189:22)
at RedisClient.on_data (/home/chas/nbb/nodebb/node_modules/redis/index.js:534:27)
at Socket.<anonymous> (/home/chas/nbb/nodebb/node_modules/redis/index.js:91:14)
at Socket.EventEmitter.emit (events.js:95:17)
[cluster] Child Process (24613) has exited (code: 1, signal: null)
[cluster] Spinning up another process...how come it works fine on this forum? :S
-
@chas Probably it's because of that line
https://github.com/Schamper/nodebb-plugin-poll/blob/master/lib/backend.js#L40
a callback should be passed there, but there is no. -
Latest master won't crash if callback isn't supplied.
dont crash if callback isnt supplied to list methods 路 NodeBB/NodeBB@749ce5f
Node.js based forum software built for the modern web - dont crash if callback isnt supplied to list methods 路 NodeBB/NodeBB@749ce5f
GitHub (github.com)
-
I swear I'll update this soon Just have to finish a large report in the next 1.5 weeks and I'll have spare time for plugin development
-
@psychobunny I tried to localize the poll plugin, but the translation doesn't happen (nodebb v0.6.x). I saw the client side js use window.templates.parse(pathToTpl, data, callback ) to process the tpl and translate string such as "[[poll.votes]]" not being replaced. Any suggestion? I guess tpl translation only happens at server side code?
-
I got the translator working by using a ':' to split the translation filename and variable, e.g.:
"[[poll:votes]]"
and my languages/ru/poll.json has:
{ "votes": "谐芯谢芯褋芯胁" }
-
I have
<a class="poll-view-result-votecount" href="#"> "[[poll:votes]]"</a>
(without the quotes)
-
err, it keeps parsing out the text
This is what i'm using
https://gist.github.com/yariplus/8fbed0308828c980e117 -
@yariplus said:
gist:8fbed0308828c980e117
GitHub Gist: instantly share code, notes, and snippets.
Gist (gist.github.com)
no luck:(
my poll.json
The result
-
@Gordon-Gu said:
@yariplus said:
gist:8fbed0308828c980e117
GitHub Gist: instantly share code, notes, and snippets.
Gist (gist.github.com)
no luck:(
my poll.json
The result
Ah okay, I should have posted my whole code. Looks like the client doesn't load the language files automatically, you have to you have to call load() first in the poll init and translate() on the template. If you can wait a bit I'm going to make a PR with everything setup.
edit: hmm, actually it does load the language automatically when you call translate(), maybe someone who knows more about the translator knows why it's not translating that template. All the admin templates work fine for me cause their parsed on the server.
edit 2: Okay! I got it working. PR coming...
-
GitHub - yariplus/nodebb-plugin-poll at translator
Poll plugin for NodeBB. Contribute to yariplus/nodebb-plugin-poll development by creating an account on GitHub.
GitHub (github.com)
Comes with Russian translations.
-
This works with 0.7.1?
-
@Leonardo-Galani Just gave this a shot on 0.7.3 and it appears to be broken on my end.
Edit: It appears to work but it doesn't display the poll on the topic.
-
with me is the following problem.
when you create is the poll not load properly with the.
the theme appears is but empty.
the code is but since. -
@Kowlin There is a pull request (not authored by me) which fixes the problem. The Javascript problem is easy to fix. However, that in and of itself does not wholly fix the problem. The second part is that the Persona theme is laid out a bit different in HTML and the poll client javascript expects to insert the poll into a certain HTML element. Altering the poll code to work correctly for Persona means breaking all other themes. I have my own fixes for these issues but haven't pushed anything because of the theme compatibility problem.
How I fixed the JS problem:
index 5eb6a09..7b78147 100644 --- a/public/js/poll/main.js +++ b/public/js/poll/main.js @@ -1,7 +1,7 @@ (function() { window.Poll = { load: function(data) { - Poll.sockets.emit.load(data.pollid, function(err, poll) + Poll.sockets.emit.load(data, function(err, poll) { if (!err) { Poll.view.init(poll, function(pollView) if (parseInt(poll.info.deleted, diff --git a/templates/poll/notify.tpl b/templates/poll/notify.tpl index a4c5354..fc693c2 100644 --- a/templates/poll/notify.tpl +++ b/templates/poll/notify.tpl @@ -1 +1 @@ -<script>Poll.load({ pollid: {pollid} })</script> \ No newline at end of file +<script>Poll.load({pollid})</script>
And how I fixed the Persona theme problem:
diff --git a/public/js/poll/view.js b/public/js/poll/view.js index 1d586ad..900f3e4 100644 --- a/public/js/poll/view.js +++ b/public/js/poll/view.js @@ -63,7 +63,7 @@ }, insertPoll: function(poll, callback) { View.parsePoll(poll, function(html) { - $('#post-container .post-row[data-index="0"] .po + $('.posts .clearfix[data-index="0"] .content').p callback(); }); },