{"_id":"@alphinex/i18n","name":"@alphinex/i18n","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@alphinex/i18n","version":"1.0.0","private":false,"description":"Locale, message-catalog, and reading-direction primitives (I18nProvider, useTranslation, getDirForLocale).","license":"UNLICENSED","type":"module","sideEffects":false,"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"dependencies":{"@alphinex/core":"1.0.0"},"peerDependencies":{"react":"^19.0.0","react-dom":"^19.0.0"},"peerDependenciesMeta":{"react":{"optional":false},"react-dom":{"optional":false}},"devDependencies":{"typescript":"^5.7.2","vite":"^6.0.5","vitest":"^2.1.8","react":"^19.0.0","react-dom":"^19.0.0","@types/react":"^19.0.2","@types/react-dom":"^19.0.2","@testing-library/react":"^16.1.0","@testing-library/jest-dom":"^6.6.3","@vitejs/plugin-react":"^4.3.4","jsdom":"^25.0.1","eslint":"^9.17.0","@alphinex/build-config":"0.0.0","@alphinex/typescript-config":"0.0.0","@alphinex/eslint-config":"0.0.0"},"scripts":{"build":"vite build","dev":"vite build --watch","lint":"eslint .","typecheck":"tsc --noEmit","test":"vitest run","clean":"rimraf dist .turbo"},"_nodeVersion":"22.14.0","_id":"@alphinex/i18n@1.0.0","dist":{"integrity":"sha512-nKNCaYP6CCZcEQPX5xBq2ixxSWz883MvOrb5cZuNLBrOw1Yn9MQ28Z5iZwwxSHavoiBuwVmrTdA6/vqgCkD5GQ==","shasum":"3f57f4003d77d30d2fbeb662d5f6eb5c02556778","tarball":"https://registry.npmjs.org/@alphinex/i18n/-/i18n-1.0.0.tgz","fileCount":5,"unpackedSize":12905,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICCo2IjSRGdQ8YHvJjBHBPdO8YkjLWJYpeugRNiScWAyAiEA7oW1NUvPfsBEezn7YGgTtf19yO9R//QQKd2sz9qWkMQ="}]},"_npmUser":{"name":"anasaliqureshi","email":"anas@alphinex.com"},"directories":{},"maintainers":[{"name":"anasaliqureshi","email":"anas@alphinex.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/i18n_1.0.0_1785858427155_0.8401780999703106"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-04T15:47:06.960Z","1.0.0":"2026-08-04T15:47:07.313Z","modified":"2026-08-04T15:47:07.571Z"},"maintainers":[{"name":"anasaliqureshi","email":"anas@alphinex.com"}],"description":"Locale, message-catalog, and reading-direction primitives (I18nProvider, useTranslation, getDirForLocale).","license":"UNLICENSED","readme":"# @alphinex/i18n\n\nLocale, message-catalog, and reading-direction primitives.\n\n## `<I18nProvider>` + `useTranslation()`\n\n```tsx\nimport { I18nProvider, useTranslation } from \"@alphinex/i18n\";\n\nconst messages = {\n  en: { greeting: \"Hello, {name}!\", nav: { settings: \"Settings\" } },\n  ar: { greeting: \"مرحبا يا {name}!\" },\n};\n\nfunction App() {\n  return (\n    <I18nProvider messages={messages} defaultLocale=\"en\">\n      <Greeting />\n    </I18nProvider>\n  );\n}\n\nfunction Greeting() {\n  const { t, locale, setLocale } = useTranslation();\n  return (\n    <>\n      <p>{t(\"greeting\", { name: \"Ada\" })}</p>\n      <button onClick={() => setLocale(\"ar\")}>عربي</button>\n    </>\n  );\n}\n```\n\n`t(key, params?)` does a dotted-key lookup (`\"nav.settings\"`) into the active locale's catalog,\nfalls back to `defaultLocale`'s catalog if a key is missing there, and finally falls back to the\nraw key if it's missing from both. `{param}` placeholders in a message string are replaced from\nthe `params` object.\n\n## `getDirForLocale(locale)`\n\nDerives reading direction from a BCP 47 locale tag. This package intentionally has no dependency\non `@alphinex/theme` — compose the two yourself so `theme` stays i18n-agnostic:\n\n```tsx\nimport { getDirForLocale, I18nProvider, useTranslation } from \"@alphinex/i18n\";\nimport { ThemeProvider } from \"@alphinex/theme\";\n\nfunction Root() {\n  return (\n    <I18nProvider messages={messages} defaultLocale=\"en\">\n      <ThemedApp />\n    </I18nProvider>\n  );\n}\n\nfunction ThemedApp() {\n  const { locale } = useTranslation();\n  return (\n    <ThemeProvider dir={getDirForLocale(locale)}>\n      <App />\n    </ThemeProvider>\n  );\n}\n```\n\nSee [documentation/ARCHITECTURE.md](../../documentation/ARCHITECTURE.md) for the full package contract, dependency rules, and roadmap placement.\n","readmeFilename":"","_rev":"1-17129f1e6dbaab31fe2642238f4ae78c"}