intl-watcher
Version:
Automated translation key extraction and dictionary management plugin for Next.js
28 lines (27 loc) • 807 B
JavaScript
import pc from "picocolors";
import { log } from "./logger.js";
import { buildIntlWatcherOptions, IntlWatcher } from "./plugin.js";
import { runOnce } from "./utils.js";
function createIntlWatcher(options) {
const fullOptions = buildIntlWatcherOptions(options);
return function withIntlWatcher(config) {
runOnce(() => setupIntlWatcher(fullOptions));
return config;
};
}
function setupIntlWatcher(options) {
const env = process.env["NODE_ENV".trim()];
if (env !== "development") {
return;
}
log.info(` \u{1F310} ${pc.blue(pc.bold("intl-watcher plugin for Next.js"))}`);
log.info();
log.success("Starting...");
const watcher = new IntlWatcher(options);
watcher.scanSourceFilesForTranslationKeys();
log.info();
watcher.startWatching();
}
export {
createIntlWatcher
};