{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-i18n",
  "type": "registry:lib",
  "title": "react-tw/lib/i18n",
  "description": "useTranslation(): the built-in Thai / English strings of core/i18n, following <html lang>. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [
    "@kanok-ui/core-i18n"
  ],
  "files": [
    {
      "path": "src/react-tw/lib/i18n.ts",
      "type": "registry:lib",
      "target": "components/ui/react-tw/lib/i18n.ts",
      "content": "import { useSyncExternalStore } from 'react';\nimport { getTranslation, onTranslationsChange, type UiTranslation } from '../../core/i18n.ts';\n\n/** Re-render on `registerTranslation` and on `<html lang>` changes. */\nfunction subscribe(onChange: () => void) {\n    const stop = onTranslationsChange(onChange);\n    const observer = typeof MutationObserver === 'undefined' ? null : new MutationObserver(onChange);\n    observer?.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] });\n    return () => {\n        stop();\n        observer?.disconnect();\n    };\n}\n\n/**\n * The language to use: `lang`, else `<html lang>`, else the browser's — the same resolution as the\n * Lit elements, without walking ancestors. On a server (and while hydrating) `lang` or English, so\n * rendering never touches the document.\n */\nexport function useLanguage(lang?: string): string {\n    return useSyncExternalStore(\n        subscribe,\n        () => lang || document.documentElement.lang || navigator.language || 'en',\n        () => lang || 'en',\n    );\n}\n\n/** The built-in strings (core/i18n, Thai and English) for the language (see useLanguage). */\nexport function useTranslation(lang?: string): UiTranslation {\n    return getTranslation(useLanguage(lang));\n}\n"
    }
  ]
}
