How intlify/vue-i18n works
Project Type and Purpose
• This is an open-source, monorepo library for internationalization in Vue 3 (Vue I18n v11).
• It publishes multiple npm packages (core, runtime, compiler, plugins, utilities) and provides documentation, examples, and CI/CD automation.
High-Level Architecture Components
a. Monorepo Root
• Configuration (tsconfig.json, rollup.config.mjs, pnpm-workspace.yaml)
• Build & Release scripts (scripts/*)
• CI/CD workflows (.github/workflows/*.yml)
b. Core Libraries Layer
• @intlify/core-base — low-level runtime, AST, formatting, fallback logic
• @intlify/core — higher-level runtime wrappers
• @intlify/shared — utilities and common code
c. Compiler Layer
• @intlify/message-compiler — parser, tokenizer, transformer for message compilation into render functions or AST
d. Vue-Integration Layer
• vue-i18n-core — Vue 3 Composition API plugin core (components, composer, symbols)
• vue-i18n — user-facing package that wraps vue-i18n-core with plugin installer
• petite-vue-i18n — lightweight variant for smaller bundles
• devtools-types — type definitions for Vue DevTools integration
e. Tools and Utilities
• format-explorer — a demo SPA to interactively explore formatting options
• size-check packages — tools to measure bundle sizes
f. Documentation & Examples
• docs/ — VitePress site with guides, API reference, and Markdown assets
• examples/ — dozens of self-contained Vue apps demonstrating various use cases (SSR, lazy loading, TSX, etc.)
Relationships & Data Flows
• The build pipeline (scripts + Rollup) uses message-compiler to precompile messages in core-base and vue-i18n-core.
• Core-base → core → vue-i18n-core → vue-i18n (layered dependency chain).
• petite variant depends on core-base directly and wraps a subset of vue-i18n-core functionality.
• format-explorer and size-check projects consume the published packages.
• CI/CD workflows run lint, build, test (Vitest + e2e), then publish packages to npm.
• docs site consumes API extractor JSON outputs from each package to generate reference pages.
Architectural Patterns & Principles
• Monorepo managed by pnpm workspace for cross-package linking and versioning.
• Layered decomposition: parsing/compiling, runtime core, framework integration, tooling.
• Shared code lives in packages/shared to avoid duplication.
• Extensive use of build-time code generation and message compilation for runtime performance.