parent
3c45c2d1e6
commit
6f7c5c50f7
@ -5,6 +5,7 @@
|
||||
import { _converse, converse } from '../../../src/headless/core.js'
|
||||
import { getHeadingButtons } from './utils.js'
|
||||
import { POLL_MESSAGE_TAG, POLL_QUESTION_TAG, POLL_CHOICE_TAG } from './constants.js'
|
||||
import { __ } from 'i18n'
|
||||
import './modals/poll-form.js'
|
||||
import './components/poll-view.js'
|
||||
import './components/poll-form-view.js'
|
||||
@ -24,6 +25,23 @@ converse.plugins.add('livechat-converse-poll', {
|
||||
_converse.api.listen.on('getHeadingButtons', getHeadingButtons)
|
||||
|
||||
_converse.api.listen.on('parseMUCMessage', (stanza, attrs) => {
|
||||
// Localizing specific error messages
|
||||
if (attrs.is_error) {
|
||||
// eslint-disable-next-line no-undef, camelcase
|
||||
if (attrs.error_text === LOC_poll_is_over) {
|
||||
// eslint-disable-next-line no-undef
|
||||
attrs.error_text = __(LOC_poll_is_over)
|
||||
// eslint-disable-next-line no-undef, camelcase
|
||||
} else if (attrs.error_text === LOC_poll_choice_invalid) {
|
||||
// eslint-disable-next-line no-undef
|
||||
attrs.error_text = __(LOC_poll_choice_invalid)
|
||||
// eslint-disable-next-line no-undef, camelcase
|
||||
} else if (attrs.error_text === LOC_poll_anonymous_vote_ok) {
|
||||
// eslint-disable-next-line no-undef
|
||||
attrs.error_text = __(LOC_poll_anonymous_vote_ok)
|
||||
}
|
||||
}
|
||||
|
||||
// Checking if there is any poll data in the message.
|
||||
const poll = sizzle(POLL_MESSAGE_TAG, stanza)?.[0]
|
||||
if (!poll) {
|
||||
@ -55,10 +73,15 @@ converse.plugins.add('livechat-converse-poll', {
|
||||
})
|
||||
}
|
||||
|
||||
// We will also translate some strings here.
|
||||
// eslint-disable-next-line no-undef
|
||||
const body = (attrs.body ?? '').replace(LOC_poll_is_over, __(LOC_poll_is_over))
|
||||
|
||||
return Object.assign(
|
||||
attrs,
|
||||
{
|
||||
current_poll: currentPoll
|
||||
current_poll: currentPoll,
|
||||
body
|
||||
}
|
||||
)
|
||||
})
|
||||
|
@ -45,7 +45,10 @@ const locKeys = [
|
||||
'poll_instructions',
|
||||
'poll_end',
|
||||
'poll',
|
||||
'poll_vote_instructions'
|
||||
'poll_vote_instructions',
|
||||
'poll_is_over',
|
||||
'poll_choice_invalid',
|
||||
'poll_anonymous_vote_ok'
|
||||
]
|
||||
|
||||
module.exports = locKeys
|
||||
|
@ -574,4 +574,7 @@ poll_anonymous_results: Anonymous results
|
||||
poll_choice_n: 'Choice {{N}}:'
|
||||
poll_end: 'Poll ends at:'
|
||||
poll_vote_instructions: |
|
||||
To vote, click on your choice or send a message with an exclamation mark followed by your choice number (Example: !1)
|
||||
To vote, click on your choice or send a message with an exclamation mark followed by your choice number (Example: !1).
|
||||
poll_is_over: This poll is now over.
|
||||
poll_choice_invalid: This choice is not valid.
|
||||
poll_anonymous_vote_ok: Your vote is taken into account. Votes are anonymous, they will not be shown to other participants.
|
||||
|
@ -554,3 +554,10 @@ poll_question: Question
|
||||
poll_duration: Durée du sondage (en minutes)
|
||||
poll_anonymous_results: Résultats anonymes
|
||||
poll_choice_n: 'Choix {{N}} :'
|
||||
poll_end: 'Fin du sondage :'
|
||||
poll_vote_instructions: |
|
||||
Pour voter, cliquez sur votre choix, ou envoyez un message avec un point d'exclamation suivi de votre choix (Exemple: !1).
|
||||
|
||||
poll_is_over: Ce sondage est à présent terminé.
|
||||
poll_choice_invalid: Ce choix n'est pas valide.
|
||||
poll_anonymous_vote_ok: Votre vote a été pris en compte. Les votes sont anonymes, ils ne seront pas montrés aux autres participant⋅es.
|
||||
|
@ -30,4 +30,4 @@ Here are the existing strings and default values:
|
||||
* poll_string_over: This poll is now over.
|
||||
* poll_string_vote_instructions: Send a message with an exclamation mark followed by your choice number to vote. Example: !1
|
||||
* poll_string_invalid_choice: This choice is not valid.
|
||||
* poll_string_anonymous_vote_ok: Your vote is taken into account. Votes are anonymous, it will not be shown to other participants.
|
||||
* poll_string_anonymous_vote_ok: Your vote is taken into account. Votes are anonymous, they will not be shown to other participants.
|
||||
|
@ -12,7 +12,7 @@ local poll_end_message = module:require("message").poll_end_message;
|
||||
local schedule_poll_update_message = module:require("message").schedule_poll_update_message;
|
||||
|
||||
local string_poll_invalid_choice = module:get_option_string("poll_string_invalid_choice") or "This choice is not valid.";
|
||||
local string_poll_anonymous_vote_ok = module:get_option_string("poll_string_anonymous_vote_ok") or "Your vote is taken into account. Votes are anonymous, it will not be shown to other participants.";
|
||||
local string_poll_anonymous_vote_ok = module:get_option_string("poll_string_anonymous_vote_ok") or "Your vote is taken into account. Votes are anonymous, they will not be shown to other participants.";
|
||||
local string_poll_over = module:get_option_string("poll_string_over") or "This poll is now over.";
|
||||
|
||||
local scheduled_end = {};
|
||||
|
@ -17,6 +17,10 @@ const locContent: Map<string, string> = new Map<string, string>()
|
||||
* - We are using keys to identify strings
|
||||
* - the `loc` function gets the english segment for the key
|
||||
* - the build-languages.js script builds all needed files.
|
||||
*
|
||||
* The loc function is also used to customize some labels on Prosody backend.
|
||||
* The front-end will then replace english strings by their translation.
|
||||
* (see mod_muc_poll for example).
|
||||
* @param key The key to translate
|
||||
*/
|
||||
function loc (key: string): string {
|
||||
|
@ -5,6 +5,7 @@
|
||||
import type { ProsodyFilePaths } from './paths'
|
||||
import type { ExternalComponent } from './components'
|
||||
import { BotConfiguration } from '../../configuration/bot'
|
||||
import { loc } from '../../loc'
|
||||
import { userInfo } from 'os'
|
||||
|
||||
/**
|
||||
@ -536,6 +537,9 @@ class ProsodyConfigContent {
|
||||
usePoll (): void {
|
||||
this.muc.add('modules_enabled', 'muc_poll')
|
||||
this.muc.set('poll_groupchat_votes_priority', 1000)
|
||||
this.muc.set('poll_string_over', loc('poll_is_over'))
|
||||
this.muc.set('poll_string_invalid_choice', loc('poll_choice_invalid'))
|
||||
this.muc.set('poll_string_anonymous_vote_ok', loc('poll_anonymous_vote_ok'))
|
||||
}
|
||||
|
||||
addMucAdmins (jids: string[]): void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user