{"_id":"@cogita/plugin-i18n","_rev":"2-437ef35557a8e7eeac63d54e94908305","name":"@cogita/plugin-i18n","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@cogita/plugin-i18n","version":"0.2.0","keywords":["cogita","plugin","i18n","internationalization","localization","rspress"],"author":{"name":"wu9o","email":"https://github.com/wu9o"},"license":"MIT","_id":"@cogita/plugin-i18n@0.2.0","maintainers":[{"name":"wu9o","email":"wu9ors@gmail.com"}],"homepage":"https://github.com/wu9o/cogita/tree/main/plugins/i18n#readme","bugs":{"url":"https://github.com/wu9o/cogita/issues"},"dist":{"shasum":"cd92cabf50866e445cbe12ede1b08df0e45d2aac","tarball":"https://registry.npmjs.org/@cogita/plugin-i18n/-/plugin-i18n-0.2.0.tgz","fileCount":8,"integrity":"sha512-lESECZi8sZ35Rnb5WvBMi0URe2lmwVV9YtPBPNh52jA4Qj9QRXHmeNYNR+ObYCaAFTF4htjRQ8bLFBfzKAOpKw==","signatures":[{"sig":"MEUCIBVnFFAHO9M2jVfZ7U5VACIcYTRGEFd5SPf15FGROj5hAiEAn4pQaY58xJYx920TNi7IDwY3lkdPXM1REPyOZSn9RrQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9697},"main":"./dist/index.js","type":"module","_from":"file:cogita-plugin-i18n-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"dev":"rslib build -w","test":"pnpm build && node --test tests/*.test.mjs","build":"rslib build","clean":"rm -rf dist"},"_npmUser":{"name":"wu9o","email":"wu9ors@gmail.com"},"_resolved":"/tmp/f7ba68e5e2eaa4d34194bd14af26c1ee/cogita-plugin-i18n-0.2.0.tgz","_integrity":"sha512-lESECZi8sZ35Rnb5WvBMi0URe2lmwVV9YtPBPNh52jA4Qj9QRXHmeNYNR+ObYCaAFTF4htjRQ8bLFBfzKAOpKw==","repository":{"url":"git+https://github.com/wu9o/cogita.git","type":"git","directory":"plugins/i18n"},"_npmVersion":"10.8.2","description":"为 Cogita 主题提供英文优先的界面文案国际化能力。","directories":{},"_nodeVersion":"18.20.8","dependencies":{"@cogita/shared":"0.13.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.4","@rslib/core":"0.11.2","@rspress/core":"^1.45.1","rsbuild-plugin-publint":"^0.3.3"},"_npmOperationalInternal":{"tmp":"tmp/plugin-i18n_0.2.0_1788404989956_0.5262085297073571","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@cogita/plugin-i18n","version":"0.3.0","description":"为 Cogita 主题提供英文优先的界面文案国际化能力。","keywords":["cogita","plugin","i18n","internationalization","localization","rspress"],"author":{"name":"wu9o","email":"https://github.com/wu9o"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/wu9o/cogita.git","directory":"plugins/i18n"},"bugs":{"url":"https://github.com/wu9o/cogita/issues"},"homepage":"https://github.com/wu9o/cogita/tree/main/plugins/i18n#readme","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./switcher":{"import":"./dist/switcher.js","default":"./dist/switcher.js"}},"main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"dependencies":{"glob":"^11.0.3","@cogita/shared":"0.13.0"},"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"devDependencies":{"@rslib/core":"0.11.2","@rspress/core":"^1.45.1","@types/react":"^19.1.9","react":"^19.1.1","rsbuild-plugin-publint":"^0.3.3","typescript":"^5.0.4"},"scripts":{"build":"rslib build","dev":"rslib build -w","clean":"rm -rf dist","test":"pnpm build && node --test tests/*.test.mjs"},"_id":"@cogita/plugin-i18n@0.3.0","_integrity":"sha512-aZhKh2wVNy0JTWJ0yl61TmKedyPQmIovIRRGnFD+/7uG692hV2uz8MJns6nk5vAZ4DAIPTW+uew+9pip8mtRkw==","_resolved":"/tmp/23fbac47a5945faaed01ecc67015b294/cogita-plugin-i18n-0.3.0.tgz","_from":"file:cogita-plugin-i18n-0.3.0.tgz","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-aZhKh2wVNy0JTWJ0yl61TmKedyPQmIovIRRGnFD+/7uG692hV2uz8MJns6nk5vAZ4DAIPTW+uew+9pip8mtRkw==","shasum":"54a7d384ee0716f36a214e5bf0da9da772f97689","tarball":"https://registry.npmjs.org/@cogita/plugin-i18n/-/plugin-i18n-0.3.0.tgz","fileCount":9,"unpackedSize":16660,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIA1o/2O7p+JnjWurcNZBlT0UtizjsFTCv97zRGCzhIshAiEAyNeXKejKKBrVqGYF+XcS2nl9f8RqeFZ5HorIiENKWEg="}]},"_npmUser":{"name":"wu9o","email":"wu9ors@gmail.com"},"directories":{},"maintainers":[{"name":"wu9o","email":"wu9ors@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-i18n_0.3.0_1788753638938_0.22530931844856772"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-03T03:09:49.767Z","modified":"2026-09-07T04:00:39.218Z","0.2.0":"2026-09-03T03:09:50.101Z","0.3.0":"2026-09-07T04:00:39.065Z"},"bugs":{"url":"https://github.com/wu9o/cogita/issues"},"author":{"name":"wu9o","email":"https://github.com/wu9o"},"license":"MIT","homepage":"https://github.com/wu9o/cogita/tree/main/plugins/i18n#readme","keywords":["cogita","plugin","i18n","internationalization","localization","rspress"],"repository":{"type":"git","url":"git+https://github.com/wu9o/cogita.git","directory":"plugins/i18n"},"description":"为 Cogita 主题提供英文优先的界面文案国际化能力。","maintainers":[{"name":"wu9o","email":"wu9ors@gmail.com"}],"readme":"# @cogita/plugin-i18n\n\nLightweight locale-aware UI copy for Cogita themes and third-party components. The plugin injects a message dictionary at build time and renders a language switcher when more than one locale is configured. Markdown content remains a site-level choice and should be authored or built as localized content separately.\n\n## Usage\n\n```ts\nimport { defineConfig } from '@cogita/core';\n\nexport default defineConfig({\n  site: { title: 'My Knowledge Base', lang: 'en-US' },\n  i18n: {\n    locale: 'en-US',\n    fallbackLocale: 'en-US',\n    messages: {\n      'en-US': {\n        'knowledge.home.search': 'Search knowledge',\n      },\n      'zh-CN': {\n        'knowledge.home.search': '搜索知识',\n      },\n    },\n  },\n  theme: '@cogita/theme-knowledge',\n});\n```\n\nThemes and plugins can import `virtual-cogita-i18n-text`:\n\n```ts\nimport { t } from 'virtual-cogita-i18n-text';\n\nconst label = t('knowledge.home.search', 'Search knowledge');\n```\n\nWhen two or more message dictionaries are configured, the plugin adds a small global language switcher. The selected locale is stored in the browser and mirrored in the `lang` query parameter so a preview can be shared.\n\nSet `showSwitcher: false` when the host theme already renders a native locale menu, such as an Rspress documentation site. For a site that publishes localized content incrementally, set `contentFallback: true` together with the Rspress `locales` config. Missing localized Markdown routes then reuse the default-language source until a file such as `content/zh-CN/guides/intro.md` is added. Existing localized files always win over the fallback route.\n\nLocale resolution checks the full identifier first (for example, `en-US`), then the language prefix (for example, `en`), and finally `fallbackLocale`. When no message is found, the caller-provided fallback is used, so older sites remain safe when the plugin is not enabled.\n\nThe content fallback only keeps locale routes reachable; it does not claim that the fallback page is translated. Article titles, Markdown, and user-provided metadata remain site-level content.\n","readmeFilename":"README.md"}