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/client/hooks/useTranslation.js

21 lines
498 B

import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { Tracker } from 'meteor/tracker';
import { useReactiveValue } from './useReactiveValue';
const translator = (key, ...replaces) => Tracker.nonreactive(() => {
if (typeof replaces[0] === 'object') {
return TAPi18n.__(key, ...replaces);
}
return TAPi18n.__(key, {
postProcess: 'sprintf',
sprintf: replaces,
});
});
export const useTranslation = () => {
useReactiveValue(() => TAPi18n.getLanguage());
return translator;
};