{"_id":"@composy/i18n-vue","name":"@composy/i18n-vue","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@composy/i18n-vue","type":"module","version":"0.0.1","description":"Vue 3 integration for @composy/i18n-core - Powerful i18n solution with composition API, components, and directives","author":{"name":"ldesign"},"license":"MIT","keywords":["i18n","internationalization","localization","vue","vue3","typescript","composition-api","reactive"],"sideEffects":false,"exports":{".":{"types":"./es/index.d.ts","import":"./es/index.js","require":"./lib/index.cjs","default":"./es/index.js"},"./components":{"types":"./es/components/index.d.ts","import":"./es/components/index.js","require":"./lib/components/index.cjs","default":"./es/components/index.js"},"./components/*":{"types":"./es/components/*.d.ts","import":"./es/components/*.js","require":"./lib/components/*.cjs","default":"./es/components/*.js"},"./composables":{"types":"./es/composables/index.d.ts","import":"./es/composables/index.js","require":"./lib/composables/index.cjs","default":"./es/composables/index.js"},"./composables/*":{"types":"./es/composables/*.d.ts","import":"./es/composables/*.js","require":"./lib/composables/*.cjs","default":"./es/composables/*.js"},"./core":{"types":"./es/core/index.d.ts","import":"./es/core/index.js","require":"./lib/core/index.cjs","default":"./es/core/index.js"},"./core/*":{"types":"./es/core/*.d.ts","import":"./es/core/*.js","require":"./lib/core/*.cjs","default":"./es/core/*.js"},"./devtools":{"types":"./es/devtools/index.d.ts","import":"./es/devtools/index.js","require":"./lib/devtools/index.cjs","default":"./es/devtools/index.js"},"./devtools/*":{"types":"./es/devtools/*.d.ts","import":"./es/devtools/*.js","require":"./lib/devtools/*.cjs","default":"./es/devtools/*.js"},"./directives":{"types":"./es/directives/index.d.ts","import":"./es/directives/index.js","require":"./lib/directives/index.cjs","default":"./es/directives/index.js"},"./directives/*":{"types":"./es/directives/*.d.ts","import":"./es/directives/*.js","require":"./lib/directives/*.cjs","default":"./es/directives/*.js"},"./plugins":{"types":"./es/plugins/index.d.ts","import":"./es/plugins/index.js","require":"./lib/plugins/index.cjs","default":"./es/plugins/index.js"},"./plugins/*":{"types":"./es/plugins/*.d.ts","import":"./es/plugins/*.js","require":"./lib/plugins/*.cjs","default":"./es/plugins/*.js"},"./utils":{"types":"./es/utils/index.d.ts","import":"./es/utils/index.js","require":"./lib/utils/index.cjs","default":"./es/utils/index.js"},"./utils/*":{"types":"./es/utils/*.d.ts","import":"./es/utils/*.js","require":"./lib/utils/*.cjs","default":"./es/utils/*.js"},"./index.css":"./dist/index.css","./index.min.css":"./dist/index.min.css","./components/LanguageSwitcher.css":"./es/components/LanguageSwitcher.css","./package.json":"./package.json"},"main":"./lib/index.cjs","module":"./es/index.js","unpkg":"./dist/index.min.js","jsdelivr":"./dist/index.min.js","types":"./es/index.d.ts","scripts":{"build":"ldesign-builder build","build:watch":"ldesign-builder build --watch","clean":"rimraf es esm lib dist coverage .tsbuildinfo tsconfig.tsbuildinfo","dev":"ldesign-builder build --watch","lint":"eslint \"src/**/*.{ts,tsx,vue}\" --fix","lint:check":"eslint \"src/**/*.{ts,tsx,vue}\"","lint:fix":"eslint \"src/**/*.{ts,tsx,vue}\" --fix","test":"ltesting run:unit","test:coverage":"ltesting run:unit --coverage","test:run":"ltesting run:unit","type-check":"vue-tsc -p tsconfig.typecheck.json --noEmit","type-check:watch":"vue-tsc -p tsconfig.typecheck.json --noEmit --watch","test:watch":"ltesting run:unit --watch","test:changed":"ltesting run:unit --changed","test:failed":"ltesting run:unit --failed","test:ui":"ltesting dashboard","postbuild":"node --experimental-strip-types ../../../../scripts/index.ts workspace:ensure-package-outputs --cwd .. --target vue && node --experimental-strip-types ../../../../scripts/index.ts clean:packages-source-declarations --cwd .. --target packages/vue"},"peerDependencies":{"vue":"^3.5.32"},"publishConfig":{"access":"public"},"peerDependenciesMeta":{"vue":{"optional":false}},"dependencies":{"@composy/i18n-core":"^0.0.1","lucide-vue-next":"^1.0.0","tslib":"^2.8.1"},"devDependencies":{"@antfu/eslint-config":"9.1.0","@composy/builder":"^0.0.1","@composy/testing":"^0.0.1","@types/node":"26.1.1","@vitejs/plugin-vue":"6.0.7","@vue/runtime-core":"3.5.39","@vue/test-utils":"^2.4.11","eslint":"10.7.0","rimraf":"^6.1.3","typescript":"5.9.3","vite":"^8.1.4","vue":"3.5.39","vue-tsc":"^3.3.7"},"typings":"./es/index.d.ts","browser":"./dist/index.js","_id":"@composy/i18n-vue@0.0.1","_nodeVersion":"23.11.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-1JgvBLkIjddyySTHsXQF70ZnVwZMMKNaH1DXHqWS2988NCTVxLip9FL6A7zR8w8DHYfBaQPz9nSisBy0QbRjTQ==","shasum":"20f3d61dbebdb5ee0665041967de82b41bd6e5ff","tarball":"https://registry.npmjs.org/@composy/i18n-vue/-/i18n-vue-0.0.1.tgz","fileCount":518,"unpackedSize":1606004,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDw6zJvNO7gFSRoRmsZRLrxgeQljcAVFogg+XOqJ2+/rgIgAVtDfgkk9oJletxfBrMdxvWClEmULyREbOsuDNuuePg="}]},"_npmUser":{"name":"swimly","email":"979741120@qq.com"},"directories":{},"maintainers":[{"name":"swimly","email":"979741120@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/i18n-vue_0.0.1_1786949447011_0.3548892292162191"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-17T06:50:45.857Z","0.0.1":"2026-08-17T06:50:47.166Z","modified":"2026-08-17T06:50:48.141Z"},"maintainers":[{"name":"swimly","email":"979741120@qq.com"}],"description":"Vue 3 integration for @composy/i18n-core - Powerful i18n solution with composition API, components, and directives","keywords":["i18n","internationalization","localization","vue","vue3","typescript","composition-api","reactive"],"author":{"name":"ldesign"},"license":"MIT","readme":"# @composy/i18n-vue\n\n`@composy/i18n-vue` 是 `@composy/i18n-core` 的 Vue\n3 适配层。它只负责把 core 中的国际化能力封装为 Vue 项目中可直接使用的插件、组合式 API、组件和指令，不重复实现 core 已有的翻译引擎与类型系统。\n\n## 安装\n\n```bash\npnpm add @composy/i18n-core @composy/i18n-vue vue\n```\n\n## 分层说明\n\n- `@composy/i18n-core`\n  - 提供框架无关的国际化核心能力\n  - 负责翻译、缓存、格式化、复数规则、插件与调试工具\n\n- `@composy/i18n-vue`\n  - 只依赖 `@composy/i18n-core` 与 `vue`\n  - 负责插件安装、Composition API、组件、指令与 Vue 场景的使用体验封装\n\n## 快速开始\n\n### 通过 `setupI18n()` 快速接入\n\n```ts\nimport { setupI18n } from '@composy/i18n-vue'\nimport { createApp } from 'vue'\nimport App from './App.vue'\n\nconst app = createApp(App)\n\nsetupI18n(app, {\n  locale: 'zh-CN',\n  fallbackLocale: 'en-US',\n  messages: {\n    'zh-CN': { hello: '你好' },\n    'en-US': { hello: 'Hello' },\n  },\n})\n\napp.mount('#app')\n```\n\n### 通过 `createI18nPlugin()` 自行管理实例\n\n```ts\nimport { createI18n, createI18nPlugin } from '@composy/i18n-vue'\nimport { createApp } from 'vue'\nimport App from './App.vue'\n\nconst i18n = createI18n({\n  locale: 'zh-CN',\n  messages: {\n    'zh-CN': { hello: '你好' },\n  },\n})\n\nconst app = createApp(App)\napp.use(createI18nPlugin(i18n))\napp.mount('#app')\n```\n\n### 在组件中使用 `useI18n()`\n\n```vue\n<script setup lang=\"ts\">\nimport { useI18n } from '@composy/i18n-vue'\n\nconst { t, locale, setLocale } = useI18n()\n</script>\n\n<template>\n  <div>\n    <h1>{{ t('hello') }}</h1>\n    <button @click=\"setLocale('zh-CN')\">\n      中文\n    </button>\n    <button @click=\"setLocale('en-US')\">\n      English\n    </button>\n  </div>\n</template>\n```\n\n## 主要能力\n\n### 插件与实例\n\n- `createI18n()`：创建 Vue 场景使用的 i18n 实例\n- `createI18nPlugin()`：创建 Vue 插件\n- `LDesignI18nPlugin`：类式安装入口\n- `setupI18n()`：一步完成实例创建与插件安装\n\n### 组合式 API\n\n- `useI18n()`：主入口，提供翻译、格式化、语言管理、消息管理\n- `useLocale()`：专注语言状态与切换\n- `useTranslation()`：带命名空间的翻译入口\n- `useI18nScope()`：组件级局部作用域封装\n- `useI18nFormat()`、`useI18nPlural()`、`useI18nAsync()` 等辅助 Hook\n\n### 组件\n\n- `I18nProvider`\n- `I18nText`\n- `I18nTranslate`\n- `I18nNumber`\n- `I18nDatetime`\n- `LanguageSwitcher`\n\n### 指令\n\n- `v-t`\n- `v-t-html`\n- `v-t-plural`\n- `v-t-tooltip`\n- `v-t-date`\n- `v-t-number`\n\n## 与 `@composy/engine-core` 集成\n\n当项目同时使用 `@composy/engine-core` 时，可通过 `createI18nEnginePlugin()` 把 core 层 engine\nplugin 与 Vue 安装流程连接起来，避免应用层重复做实例注入和安装逻辑。\n\n## 工具函数\n\n- `defineI18nConfig()`：定义类型安全的配置对象\n- `loadLocaleMessages()`：统一加载动态语言包\n\n## 开发命令\n\n```bash\npnpm build\npnpm type-check\npnpm lint:check\npnpm test\n```\n\n## 注意事项\n\n- 当前包是 Vue 3 适配层，不应承载框架无关的核心逻辑。\n- 如果需要扩展翻译算法、缓存、插件协议或类型定义，应优先修改 `@composy/i18n-core`。\n- 当前 `pnpm type-check` 使用本地专用配置 `tsconfig.typecheck.json`，直接校验 `@composy/i18n-core`\n  源码而不依赖预构建声明。\n\n## 许可证\n\n```ts\ncreateI18nEnginePlugin({\n  installVuePlugin: false,\n  locale: 'en',\n  messages: {\n    en: { hello: 'Hello' },\n  },\n})\n```\n\n## 目录结构\n\n```text\nsrc/\n├── components/\n│   ├── I18nText.tsx\n│   ├── I18nNumber.tsx\n│   ├── I18nDatetime.tsx\n│   ├── I18nProvider.tsx\n│   └── LanguageSwitcher.tsx\n├── composables/\n│   ├── useI18n.ts\n│   ├── useLocale.ts\n│   └── ...\n├── core/\n│   ├── constants.ts\n│   ├── plugin-options.ts\n│   └── types.ts\n├── directives/\n│   ├── vT.ts\n│   ├── vTHtml.ts\n│   ├── vTPlural.ts\n│   └── ...\n├── plugins/\n│   ├── createI18nPlugin.ts\n│   ├── createI18nEnginePlugin.ts\n│   └── installVueI18n.ts\n├── utils/\n│   ├── createI18n.ts\n│   ├── defineI18nConfig.ts\n│   ├── loadLocaleMessages.ts\n│   └── setupI18n.ts\n└── index.ts\n```\n\n职责约束：\n\n- `core/` 只放 Vue 适配层共享类型、注入键和配置模型\n- `plugins/` 只放安装入口和 bridge，不承载业务逻辑\n- `utils/` 只放实例创建、配置声明和加载辅助函数\n- `components/`、`directives/`、`composables/` 只放 Vue 表层能力\n\n## API 概览\n\n- `createI18n(config)`：创建并初始化 i18n 实例\n- `createI18nPlugin(i18n, options)`：原生 Vue Plugin 安装入口\n- `createI18nEnginePlugin(options)`：`@composy/engine-core` bridge 入口\n- `setupI18n(app, config, pluginOptions?)`：快速创建并安装\n- `useI18n()` / `useLocale()` / `useTranslation()`：组合式 API\n\n## 说明\n\n- `localeSwitcher` 配置通过统一的 Vue 安装内核提供给 `LanguageSwitcher`\n- 原生 Vue Plugin 与 engine plugin 最终都会走 `installVueI18n(...)`\n- `packages/vue` 不再声明不存在的全局 CSS 产物，组件样式由组件自身显式引入\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-33867d6aff4b93fe0067bc8ebe9e7ecb"}