Skip to content

Commit

Permalink
refactor(i18n): Use i18next API to get a fixed t-function (#33586)
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan authored and abhinavkrin committed Oct 25, 2024
1 parent 71fe884 commit 86272e5
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/2fa/server/code/EmailCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class EmailCheck implements ICodeCheck {
private async send2FAEmail(address: string, random: string, user: IUser): Promise<void> {
const language = user.language || settings.get('Language') || 'en';

const t = (s: string): string => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);

await Mailer.send({
to: address,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/2fa/server/functions/resetTOTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const sendResetNotification = async function (uid: string): Promise<void> {
return;
}

const t = (s: string): string => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);
const text = `
${t('Your_TOTP_has_been_reset')}
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/api/v1/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ API.v1.addRoute(
const visitorEmail = visitor.visitorEmails?.[0]?.address;

const language = servingAgent.language || rcSettings.get<string>('Language') || 'en';
const t = (s: string): string => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);
const subject = t('Transcript_of_your_livechat_conversation');

options.emailTranscript = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { logger } from './logger';
type FileAttachment = VideoAttachmentProps & ImageAttachmentProps & AudioAttachmentProps;

const language = settings.get<string>('Language') || 'en';
const t = (s: string): string => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);

async function getGuestByEmail(email: string, name: string, department = ''): Promise<ILivechatVisitor | null> {
const guest = await LivechatVisitors.findOneGuestByEmailAddress(email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const livechatQuoteRegExp = /^\[\s\]\(https?:\/\/.+\/live\/.+\?msg=(?<id>.+?)\)\
const getRocketCatUser = async (): Promise<IUser | null> => Users.findOneById('rocket.cat');

const language = settings.get<string>('Language') || 'en';
const t = (s: string): string => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);

// TODO: change these messages with room notifications
const sendErrorReplyMessage = async (error: string, options: any) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/lib/resetUserE2EKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const sendResetNotification = async function (uid: string): Promise<void> {
return;
}

const t = (s: string): string => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);
const text = `
${t('Your_e2e_key_has_been_reset')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class OmnichannelAnalyticsService extends ServiceClassInternal implements
return;
}

const t = (s: string) => i18n.t(s, { lng: language });
const t = i18n.getFixedT(language);

const extraQuery = await callbacks.run('livechat.applyRoomRestrictions', {});
return this.overview.callAction(name, from, to, departmentId, timezone, t, extraQuery);
Expand Down

0 comments on commit 86272e5

Please sign in to comment.