const localeModules = import.meta.glob<{ default: Record<string, unknown> }>('./*.ts')

export async function loadLocaleMessages(locale: string) {
  const path = `./${locale}.ts`
  const loader = localeModules[path]
  if (!loader) {
    throw new Error(`Locale not found: ${locale}`)
  }
  const mod = await loader()
  return mod.default ?? {}
}
