Also remove top-level i18n declarations in components
This commit is contained in:
JC Brand 2020-08-17 08:53:08 +02:00
parent 11cd6b8321
commit 306b9fdd71
4 changed files with 67 additions and 66 deletions

View File

@ -10,34 +10,28 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
const { Strophe, $iq } = converse.env; const { Strophe, $iq } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
const i18n_hide = __('Hide');
const i18n_choose_service = __('On which entity do you want to run commands?');
const i18n_choose_service_instructions = __(
'Certain XMPP services and entities allow privileged users to execute ad-hoc commands on them.');
const i18n_commands_found = __('Commands found');
const i18n_fetch_commands = __('List available commands');
const i18n_jid_placeholder = __('XMPP Address');
const i18n_no_commands_found = __('No commands found');
const i18n_run = __('Execute');
const tpl_command_form = (o, command) => {
const i18n_hide = __('Hide');
const i18n_run = __('Execute');
return html`
<form @submit=${o.runCommand}>
${ command.alert ? html`<div class="alert alert-${command.alert_type}" role="alert">${command.alert}</div>` : '' }
<fieldset class="form-group">
<input type="hidden" name="command_node" value="${command.node}"/>
<input type="hidden" name="command_jid" value="${command.jid}"/>
const tpl_command_form = (o, command) => html` <p class="form-help">${command.instructions}</p>
<form @submit=${o.runCommand}> <!-- Fields are generated internally, with xForm2webForm -->
${ command.alert ? html`<div class="alert alert-${command.alert_type}" role="alert">${command.alert}</div>` : '' } ${ command.fields.map(field => unsafeHTML(field)) }
<fieldset class="form-group"> </fieldset>
<input type="hidden" name="command_node" value="${command.node}"/> <fieldset>
<input type="hidden" name="command_jid" value="${command.jid}"/> <input type="submit" class="btn btn-primary" value="${i18n_run}">
<input type="button" class="btn btn-secondary button-cancel" value="${i18n_hide}" @click=${o.hideCommandForm}>
<p class="form-help">${command.instructions}</p> </fieldset>
<!-- Fields are generated internally, with xForm2webForm --> </form>
${ command.fields.map(field => unsafeHTML(field)) } `;
</fieldset> }
<fieldset>
<input type="submit" class="btn btn-primary" value="${i18n_run}">
<input type="button" class="btn btn-secondary button-cancel" value="${i18n_hide}" @click=${o.hideCommandForm}>
</fieldset>
</form>
`;
const tpl_command = (o, command) => html` const tpl_command = (o, command) => html`
@ -62,33 +56,42 @@ async function getAutoCompleteList () {
return jids; return jids;
} }
const tpl_adhoc = (o) => html` const tpl_adhoc = (o) => {
${ o.alert ? html`<div class="alert alert-${o.alert_type}" role="alert">${o.alert}</div>` : '' } const i18n_choose_service = __('On which entity do you want to run commands?');
<form class="converse-form" @submit=${o.fetchCommands}> const i18n_choose_service_instructions = __(
<fieldset class="form-group"> 'Certain XMPP services and entities allow privileged users to execute ad-hoc commands on them.');
<label> const i18n_commands_found = __('Commands found');
${i18n_choose_service} const i18n_fetch_commands = __('List available commands');
<p class="form-help">${i18n_choose_service_instructions}</p> const i18n_jid_placeholder = __('XMPP Address');
<converse-autocomplete const i18n_no_commands_found = __('No commands found');
.getAutoCompleteList="${getAutoCompleteList}" return html`
placeholder="${i18n_jid_placeholder}" ${ o.alert ? html`<div class="alert alert-${o.alert_type}" role="alert">${o.alert}</div>` : '' }
name="jid"/> <form class="converse-form" @submit=${o.fetchCommands}>
</label> <fieldset class="form-group">
</fieldset> <label>
<fieldset class="form-group"> ${i18n_choose_service}
<input type="submit" class="btn btn-primary" value="${i18n_fetch_commands}"> <p class="form-help">${i18n_choose_service_instructions}</p>
</fieldset> <converse-autocomplete
${ o.view === 'list-commands' ? html` .getAutoCompleteList="${getAutoCompleteList}"
<fieldset class="form-group"> placeholder="${i18n_jid_placeholder}"
<ul class="list-group"> name="jid"/>
<li class="list-group-item active">${ o.commands.length ? i18n_commands_found : i18n_no_commands_found }:</li> </label>
${ o.commands.map(cmd => tpl_command(o, cmd)) } </fieldset>
</ul> <fieldset class="form-group">
</fieldset>` <input type="submit" class="btn btn-primary" value="${i18n_fetch_commands}">
: '' } </fieldset>
${ o.view === 'list-commands' ? html`
<fieldset class="form-group">
<ul class="list-group">
<li class="list-group-item active">${ o.commands.length ? i18n_commands_found : i18n_no_commands_found }:</li>
${ o.commands.map(cmd => tpl_command(o, cmd)) }
</ul>
</fieldset>`
: '' }
</form> </form>
`; `;
}
async function fetchCommandForm (command) { async function fetchCommandForm (command) {

View File

@ -16,11 +16,6 @@ import { renderAvatar } from './../templates/directives/avatar';
const { Strophe } = converse.env; const { Strophe } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
const i18n_edited = __('This message has been edited');
const i18n_show = __('Show more');
const i18n_show_less = __('Show less');
const i18n_uploading = __('Uploading file:');
export default class Message extends CustomElement { export default class Message extends CustomElement {
@ -112,6 +107,7 @@ export default class Message extends CustomElement {
} }
renderFileProgress () { renderFileProgress () {
const i18n_uploading = __('Uploading file:');
const filename = this.model.file.name; const filename = this.model.file.name;
const size = filesize(this.model.file.size); const size = filesize(this.model.file.size);
return html` return html`
@ -214,7 +210,11 @@ export default class Message extends CustomElement {
} }
renderMessageText () { renderMessageText () {
const i18n_edited = __('This message has been edited');
const i18n_show = __('Show more');
const is_groupchat_message = (this.message_type === 'groupchat'); const is_groupchat_message = (this.message_type === 'groupchat');
const i18n_show_less = __('Show less');
const tpl_spoiler_hint = html` const tpl_spoiler_hint = html`
<div class="chat-msg__spoiler-hint"> <div class="chat-msg__spoiler-hint">
<span class="spoiler-hint">${this.spoiler_hint}</span> <span class="spoiler-hint">${this.spoiler_hint}</span>

View File

@ -7,13 +7,6 @@ import { until } from 'lit-html/directives/until.js';
const Strophe = converse.env.Strophe const Strophe = converse.env.Strophe
const i18n_chars_remaining = __('Message characters remaining');
const i18n_choose_file = __('Choose a file to send')
const i18n_hide_occupants = __('Hide occupants');
const i18n_send_message = __('Send the message');
const i18n_show_occupants = __('Show occupants');
const i18n_start_call = __('Start a call');
export class ChatToolbar extends CustomElement { export class ChatToolbar extends CustomElement {
@ -35,6 +28,7 @@ export class ChatToolbar extends CustomElement {
} }
render () { render () {
const i18n_send_message = __('Send the message');
return html` return html`
${ this.show_toolbar ? html`<span class="toolbar-buttons">${until(this.getButtons(), '')}</span>` : '' } ${ this.show_toolbar ? html`<span class="toolbar-buttons">${until(this.getButtons(), '')}</span>` : '' }
${ this.show_send_button ? html`<button type="submit" class="btn send-button fa fa-paper-plane" title="${ i18n_send_message }"></button>` : '' } ${ this.show_send_button ? html`<button type="submit" class="btn send-button fa fa-paper-plane" title="${ i18n_send_message }"></button>` : '' }
@ -49,12 +43,14 @@ export class ChatToolbar extends CustomElement {
} }
if (this.show_call_button) { if (this.show_call_button) {
const i18n_start_call = __('Start a call');
buttons.push(html` buttons.push(html`
<button class="toggle-call" @click=${this.toggleCall} title="${i18n_start_call}"> <button class="toggle-call" @click=${this.toggleCall} title="${i18n_start_call}">
<converse-icon class="fa fa-phone" path-prefix="/dist" size="1em"></converse-icon> <converse-icon class="fa fa-phone" path-prefix="/dist" size="1em"></converse-icon>
</button>` </button>`
); );
} }
const i18n_chars_remaining = __('Message characters remaining');
const message_limit = api.settings.get('message_limit'); const message_limit = api.settings.get('message_limit');
if (message_limit) { if (message_limit) {
buttons.push(html`<span class="right message-limit" title="${i18n_chars_remaining}">${this.message_limit}</span>`); buttons.push(html`<span class="right message-limit" title="${i18n_chars_remaining}">${this.message_limit}</span>`);
@ -68,6 +64,8 @@ export class ChatToolbar extends CustomElement {
buttons.push(html`${until(http_upload_promise.then(is_supported => this.getHTTPUploadButton(is_supported)),'')}`); buttons.push(html`${until(http_upload_promise.then(is_supported => this.getHTTPUploadButton(is_supported)),'')}`);
if (this.show_occupants_toggle) { if (this.show_occupants_toggle) {
const i18n_hide_occupants = __('Hide participants');
const i18n_show_occupants = __('Show participants');
buttons.push(html` buttons.push(html`
<button class="toggle_occupants right" <button class="toggle_occupants right"
title="${this.hidden_occupants ? i18n_show_occupants : i18n_hide_occupants}" title="${this.hidden_occupants ? i18n_show_occupants : i18n_hide_occupants}"
@ -85,9 +83,9 @@ export class ChatToolbar extends CustomElement {
return _converse.api.hook('getToolbarButtons', this, buttons); return _converse.api.hook('getToolbarButtons', this, buttons);
} }
getHTTPUploadButton (is_supported) { getHTTPUploadButton (is_supported) {
if (is_supported) { if (is_supported) {
const i18n_choose_file = __('Choose a file to send')
return html` return html`
<button title="${i18n_choose_file}" @click=${this.toggleFileUpload}> <button title="${i18n_choose_file}" @click=${this.toggleFileUpload}>
<converse-icon class="fa fa-paperclip" <converse-icon class="fa fa-paperclip"

View File

@ -313,7 +313,7 @@ converse.plugins.add('converse-muc-views', {
} else if (state === 'op') { } else if (state === 'op') {
return `${result}${__("%1$s are now moderators", actors[0])}\n`; return `${result}${__("%1$s are now moderators", actors[0])}\n`;
} else if (state === 'deop') { } else if (state === 'deop') {
return `${result}${__("%1$s are no longer moderator", actors[0])}\n`; return `${result}${__("%1$s are no longer moderators", actors[0])}\n`;
} else if (state === 'voice') { } else if (state === 'voice') {
return `${result}${__("%1$s have been given voices", actors[0])}\n`; return `${result}${__("%1$s have been given voices", actors[0])}\n`;
} else if (state === 'mute') { } else if (state === 'mute') {