import { loadJSON } from "./loadJSON";

// Provide an standalone localize utility not managed by next-i18n
export async function localize(locale: string) {
  const localeModule = `../../../../packages/i18n/locales/${locale}/common.json`;
  const localeMap = loadJSON(localeModule);
  return (message: string) => {
    if (message in localeMap) return localeMap[message];
    throw "No locale found for the given entry message";
  };
}
