UNPKG

next-intl

Version:

Internationalization (i18n) for Next.js

23 lines (20 loc) 773 B
import { warn } from '../plugin/utils.js'; import ExtractionCompiler from './ExtractionCompiler.js'; import MessageExtractor from './extractor/MessageExtractor.js'; import normalizeExtractorConfig from './normalizeExtractorConfig.js'; import { hasLocalesToExtract, getDefaultProjectRoot } from './utils.js'; async function extractMessages(params) { const config = normalizeExtractorConfig(params); if (!hasLocalesToExtract(config)) { warn('`messages.locales` is empty, so no messages were updated.'); return; } const compiler = new ExtractionCompiler(config, { extractor: new MessageExtractor({ isDevelopment: false, projectRoot: getDefaultProjectRoot() }) }); await compiler.extractAll(); } export { extractMessages as default };