import { cn, us } from "./resources.js";
const resources = { us, cn };
let currentLanguage = "us";
function setLanguage(lang) {
  currentLanguage = lang;
}
function interpolate(template, params) {
  if (!params) return template;
  return template.replace(/\{(.*?)\}/g, (_, k) => String(params[k] ?? ""));
}
function t(ns, key, params) {
  const langDict = resources[currentLanguage] ?? resources.us;
  const dict = langDict?.[ns];
  const value = dict?.[key];
  if (typeof value === "string") return interpolate(value, params);
  const fallback = resources.us[ns]?.[key];
  return typeof fallback === "string" ? interpolate(fallback, params) : key;
}
export {
  setLanguage,
  t
};
//# sourceMappingURL=index.js.map
