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';
|
|
|
|
|
2023-05-18 08:20:06 +02:00
|
|
|
export function useMessages() {
|
2023-03-22 05:28:36 +01:00
|
|
|
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
|
|
|
}
|
2023-05-18 08:20:06 +02:00
|
|
|
|
|
|
|
export default useMessages;
|