How lingui/js-lingui works
Main Components Overview
a) Core Components:
• @lingui/core (Core i18n functionality)
• @lingui/react (React integration layer)
• Message Catalog System
• CLI Tools & Build Pipeline
b) Integration Components:
• Vite Plugin
• Webpack Loader
• Metro Transformer
• SWC Plugin
• Format Handlers (PO, JSON, CSV)
Architecture Layers
┌─────────────────────────────────────────────┐
• Application Layer │
• (React, React Native, JavaScript Apps) │
• ┤
• Integration Layer │
• (Vite, Webpack, Metro, SWC Integration) │
• ┤
• Runtime Layer │
• (@lingui/react, React Components) │
• ┤
• Core Layer │
• (@lingui/core, Message Format Engine) │
• ┤
• Build-time Layer │
• (CLI, Extraction, Compilation) │
• ┘
Data Flow Representation
• Message extraction flow
• Compilation process
• Runtime message loading
• Translation rendering pipeline
[Source Code] → [Extraction] → [Translation Files] → [Compilation] → [Runtime Messages]
[Application] → [@lingui/react] → [@lingui/core] → [Formatted Output]
Component Relationships
Interactions between:
• CLI tools and message catalogs
• Build plugins and compilation process
• React components and core formatting engine
• Format handlers and message storage
Optimization Features
Highlight:
• 3kb core bundle size
• Compilation optimization
• Dynamic loading capabilities
• Server-side rendering support
• Universal usage across platforms
• Clean developer experience
• Powerful tooling integration
• Optimized runtime performance