Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
20 lines
629 B
Plaintext
20 lines
629 B
Plaintext
import { cache } from 'react';
|
|
import getConfig from './getConfig.js';
|
|
|
|
function getMessagesFromConfig(config) {
|
|
if (!config.messages) {
|
|
throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages');
|
|
}
|
|
return config.messages;
|
|
}
|
|
async function getMessagesCachedImpl(locale) {
|
|
const config = await getConfig(locale);
|
|
return getMessagesFromConfig(config);
|
|
}
|
|
const getMessagesCached = cache(getMessagesCachedImpl);
|
|
async function getMessages(opts) {
|
|
return getMessagesCached(opts?.locale);
|
|
}
|
|
|
|
export { getMessages as default, getMessagesFromConfig };
|