The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/utils/lib/i18n.ts

23 lines
598 B

import i18next from 'i18next';
import sprintf from 'i18next-sprintf-postprocessor';
import { isObject } from '../../../lib/utils/isObject';
export const i18n = i18next.use(sprintf);
export const addSprinfToI18n = function (t: (typeof i18n)['t']): typeof t & {
(key: string, ...replaces: any): string;
} {
return function (key: string, ...replaces: any): string {
if (replaces[0] === undefined || isObject(replaces[0])) {
return t(key, ...replaces);
}
return t(key, {
postProcess: 'sprintf',
sprintf: replaces,
});
};
};
export const t = addSprinfToI18n(i18n.t.bind(i18n));