umami/hooks/useMessages.js

15 lines
431 B
JavaScript
Raw Normal View History

2023-03-22 22:05:55 +01:00
import { useIntl, FormattedMessage } from 'react-intl';
2023-03-22 05:28:36 +01:00
import { messages, labels } from 'components/messages';
export default function useMessages() {
const { formatMessage } = useIntl();
2023-03-22 22:05:55 +01:00
function getMessage(id) {
const message = Object.values(messages).find(value => value.id === id);
return message ? formatMessage(message) : id;
}
return { formatMessage, FormattedMessage, messages, labels, getMessage };
2023-03-22 05:28:36 +01:00
}