@@ -28,75 +28,81 @@ pnpm add @lingo.dev/compiler
2828yarn add @lingo.dev/compiler
2929```
3030
31- ## Quick Start
31+ ## Structure
3232
33- ## Usage with Turbopack (Next.js 16+)
33+ The compiler is organized into several key modules:
3434
35- ### 1. Configure Next.js
35+ ### Core Directories
3636
37- [ // ] : # ( TODO (AleksandrSl 12/12/2025):
37+ #### ` src/plugin/ ` - Build-time transformation
3838
39- ### 2. (Optional) Use directive mode
39+ - ** ` transform/ ` ** - Babel AST transformation logic for JSX text extraction
40+ - ** ` unplugin.ts ` ** - Universal plugin implementation (Vite, Webpack, Rollup, esbuild)
41+ - ** ` next.ts ` ** - Next.js-specific plugin with Turbopack and webpack support
42+ - ** ` build-translator.ts ` ** - Batch translation generation at build time
43+ - ** ` locale-code-generator.ts ` ** - Generates locale resolver modules
4044
41- If you set ` useDirective: true ` , add the directive to files you want to translate:
45+ #### ` src/metadata/ ` - Translation metadata management
4246
43- ``` tsx
44- " use i18n" ;
47+ - ** ` manager.ts ` ** - CRUD operations for ` .lingo/metadata.json `
48+ - Thread-safe metadata file operations with locking
49+ - Manages translation entries with hash-based identifiers
4550
46- export function MyComponent() {
47- return <div >This text will be translated</div >;
48- }
49- ```
51+ #### ` src/translators/ ` - Translation provider abstraction
5052
51- ### 3. Write components normally
52-
53- ``` tsx
54- // src/components/Welcome.tsx
55- export function Welcome() {
56- return (
57- <div >
58- <h1 >Welcome to our site</h1 >
59- <p >This text will be automatically translated</p >
60- </div >
61- );
62- }
63- ```
53+ - ** ` lcp/ ` ** - Lingo.dev Engine integration
54+ - ** ` pseudotranslator/ ` ** - Development-mode fake translator
55+ - ** ` pluralization/ ` ** - Automatic ICU MessageFormat detection
56+ - ** ` translator-factory.ts ` ** - Provider selection and initialization
6457
65- ### 4. Build and see transformations
58+ #### ` src/translation-server/ ` - Development server
6659
67- After build, the code will be transformed to:
60+ - ** ` translation-server.ts ` ** - HTTP server for on-demand translations
61+ - ** ` cli.ts ` ** - Standalone CLI for translation generation
62+ - WebSocket support for real-time dev widget updates
63+ - Port management (60000-60099 range)
6864
69- ``` tsx
70- import { useTranslation } from " @lingo.dev/runtime" ;
65+ #### ` src/react/ ` - Runtime translation hooks
7166
72- export function Welcome() {
73- const t = useTranslation ();
74- return (
75- <div >
76- <h1 >{ t (" a1b2c3d4e5f6" )} </h1 >
77- <p >{ t (" f6e5d4c3b2a1" )} </p >
78- </div >
79- );
80- }
81- ```
67+ - ** ` client/ ` ** - Client-side Context-based hooks
68+ - ** ` server/ ` ** - Server component cache-based hooks (isomorphic)
69+ - ** ` server-only/ ` ** - Async server-only API (` getServerTranslations ` )
70+ - ** ` shared/ ` ** - Shared utilities (RichText rendering, Context)
71+ - ** ` next/ ` ** - Next.js-specific middleware and locale switcher
72+
73+ #### ` src/utils/ ` - Shared utilities
74+
75+ - ** ` hash.ts ` ** - Stable hash generation for translation keys
76+ - ** ` config-factory.ts ` ** - Configuration defaults and merging
77+ - ** ` logger.ts ` ** - Structured logging utilities
78+ - ** ` path-helpers.ts ` ** - File path resolution
79+
80+ #### ` src/widget/ ` - Development widget
81+
82+ - In-browser translation editor overlay for development mode
83+
84+ ### Support Directories
85+
86+ #### ` tests/ ` - End-to-end testing
8287
83- ## How It Works
88+ - ** ` e2e/ ` ** - Playwright tests for full build workflows
89+ - ** ` fixtures/ ` ** - Test applications (Vite, Next.js)
90+ - ** ` helpers/ ` ** - Test utilities and assertions
8491
85- [ // ] : # ( TODO (AleksandrSl 12/12/2025):
92+ #### ` benchmarks/ ` - Performance benchmarks
8693
87- ## Limitations (Current Version)
94+ - Translation speed benchmarks
95+ - Metadata I/O performance tests
8896
89- - Requires manual runtime setup (TranslationProvider, etc.)
97+ #### ` old-docs/ ` - Legacy documentation
9098
91- ## Supported Bundlers
99+ - Historical design documents and notes
92100
93- | Bundler | Status | Import Path |
94- | ------- | --------------- | ----------------------------- |
95- | Vite | ✅ Full Support | ` @lingo.dev/compiler/vite ` |
96- | Webpack | ✅ Full Support | ` @lingo.dev/compiler/webpack ` |
97- | Next.js | ✅ Full Support | ` @lingo.dev/compiler/next ` |
101+ ### Entry Points
98102
99- All bundler plugins share the same configuration API.
103+ - ** ` src/index.ts ` ** - Main package exports (plugins, types)
104+ - ** ` src/types.ts ` ** - Core TypeScript types
105+ - ** ` src/dev-config.ts ` ** - Development configuration utilities
100106
101107## Contributing
102108
0 commit comments