Skip to content

Commit

Permalink
Don't import from i18n in headless
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Apr 2, 2022
1 parent f6a985c commit fb704fd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/headless/plugins/bookmarks/collection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "@converse/headless/plugins/muc/index.js";
import Bookmark from './model.js';
import log from "@converse/headless/log.js";
import { __ } from 'i18n';
import { _converse, api, converse } from "@converse/headless/core";
import { getOpenPromise } from '@converse/openpromise';
import { initStorage } from '@converse/headless/utils/storage.js';
Expand Down Expand Up @@ -86,6 +85,7 @@ const Bookmarks = {
},

onBookmarkError (iq, options) {
const { __ } = _converse;
log.error("Error while trying to add bookmark");
log.error(iq);
api.alert(
Expand Down Expand Up @@ -145,6 +145,7 @@ const Bookmarks = {
},

onBookmarksReceivedError (deferred, iq) {
const { __ } = _converse;
if (iq === null) {
log.error('Error: timeout while fetching bookmarks');
api.alert('error', __('Timeout Error'),
Expand Down
3 changes: 2 additions & 1 deletion src/headless/plugins/roster/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import log from "@converse/headless/log";
import sum from 'lodash-es/sum';
import { Collection } from "@converse/skeletor/src/collection";
import { Model } from "@converse/skeletor/src/model";
import { __ } from 'i18n';
import { _converse, api, converse } from "@converse/headless/core";
import { initStorage } from '@converse/headless/utils/storage.js';
import { rejectPresenceSubscription } from './utils.js';
Expand Down Expand Up @@ -163,6 +162,7 @@ const RosterContacts = Collection.extend({
try {
await this.sendContactAddIQ(jid, name, groups);
} catch (e) {
const { __ } = _converse;
log.error(e);
alert(__('Sorry, there was an error while trying to add %1$s as a contact.', name || jid));
return e;
Expand Down Expand Up @@ -355,6 +355,7 @@ const RosterContacts = Collection.extend({
contact = this.get(bare_jid);

if (!api.settings.get('allow_contact_requests')) {
const { __ } = _converse;
rejectPresenceSubscription(
jid,
__("This client does not allow presence subscriptions")
Expand Down
2 changes: 1 addition & 1 deletion src/headless/plugins/roster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import RosterContact from './contact.js';
import RosterContacts from './contacts.js';
import roster_api from './api.js';
import { Presence, Presences } from './presence.js';
import { __ } from 'i18n';
import { _converse, api, converse } from '@converse/headless/core';
import {
onChatBoxesInitialized,
Expand All @@ -34,6 +33,7 @@ converse.plugins.add('converse-roster', {
// API methods only available to plugins
Object.assign(_converse.api, roster_api);

const { __ } = _converse;
_converse.HEADER_CURRENT_CONTACTS = __('My contacts');
_converse.HEADER_PENDING_CONTACTS = __('Pending contacts');
_converse.HEADER_REQUESTING_CONTACTS = __('Contact requests');
Expand Down

0 comments on commit fb704fd

Please sign in to comment.