|
| 1 | +# @lingo.dev/compiler |
| 2 | + |
| 3 | +See the main [README](../README.md) for general information. |
| 4 | + |
| 5 | +## Structure |
| 6 | + |
| 7 | +The compiler is organized into several key modules: |
| 8 | + |
| 9 | +### Core Directories |
| 10 | + |
| 11 | +#### `src/plugin/` - Build-time transformation |
| 12 | + |
| 13 | +- **`transform/`** - Babel AST transformation logic for JSX text extraction |
| 14 | +- **`unplugin.ts`** - Universal plugin implementation (Vite, Webpack) |
| 15 | +- **`next.ts`** - Next.js-specific plugin with Turbopack and Webpack support |
| 16 | +- **`build-translator.ts`** - Batch translation generation at build time |
| 17 | +- **`virtual-modules-code-generator.ts`** - Generates code for virtual modules, dev config and locale resolvers for client and server |
| 18 | + |
| 19 | +#### `src/metadata/` - Translation metadata management |
| 20 | + |
| 21 | +- **`manager.ts`** - CRUD operations for `.lingo/metadata.json` |
| 22 | +- Thread-safe metadata file operations with file locking |
| 23 | +- Manages translation entries with hash-based identifiers |
| 24 | + |
| 25 | +#### `src/translators/` - Translation provider abstraction |
| 26 | + |
| 27 | +- **`lcp/`** - Lingo.dev Engine integration |
| 28 | +- **`pseudotranslator/`** - Development-mode fake translator |
| 29 | +- **`pluralization/`** - Automatic ICU MessageFormat detection |
| 30 | +- **`translator-factory.ts`** - Provider selection and initialization |
| 31 | + |
| 32 | +#### `src/translation-server/` - Development server |
| 33 | + |
| 34 | +- **`translation-server.ts`** - HTTP server for on-demand translations |
| 35 | +- **`cli.ts`** - Standalone CLI for translation generation |
| 36 | +- WebSocket support for real-time dev widget updates |
| 37 | +- Port management (60000-60099 range) |
| 38 | + |
| 39 | +#### `src/react/` - Runtime translation hooks |
| 40 | + |
| 41 | +- **`client/`** - Client-side Context-based hooks |
| 42 | +- **`server/`** - Server component cache-based hooks (isomorphic) |
| 43 | +- **`server-only/`** - Async server-only API (`getServerTranslations`) |
| 44 | +- **`shared/`** - Shared utilities (RichText rendering, Context) |
| 45 | +- **`next/`** - Next.js-specific middleware and locale switcher |
| 46 | + |
| 47 | +#### `src/utils/` - Shared utilities |
| 48 | + |
| 49 | +- **`hash.ts`** - Stable hash generation for translation keys |
| 50 | +- **`config-factory.ts`** - Configuration defaults and merging |
| 51 | +- **`logger.ts`** - Structured logging utilities |
| 52 | +- **`path-helpers.ts`** - File path resolution |
| 53 | + |
| 54 | +#### `src/widget/` - Development widget |
| 55 | + |
| 56 | +- In-browser translation editor overlay for development mode |
| 57 | + |
| 58 | +### Support Directories |
| 59 | + |
| 60 | +#### `tests/` - End-to-end testing |
| 61 | + |
| 62 | +- **`e2e/`** - Playwright tests for full build workflows |
| 63 | +- **`fixtures/`** - Test applications (Vite, Next.js) |
| 64 | +- **`helpers/`** - Test utilities and assertions |
| 65 | + |
| 66 | +#### `benchmarks/` - Performance benchmarks |
| 67 | + |
| 68 | +- Translation speed benchmarks |
| 69 | +- Metadata I/O performance tests |
| 70 | + |
| 71 | +#### `old-docs/` - Legacy documentation |
| 72 | + |
| 73 | +- Historical design documents and notes |
| 74 | + |
| 75 | +### Entry Points |
| 76 | + |
| 77 | +- **`src/index.ts`** - Main package exports (plugins, types) |
| 78 | +- **`src/types.ts`** - Core TypeScript types |
| 79 | + |
| 80 | +## Contributing |
| 81 | + |
| 82 | +This is a beta package under active development. Feedback and contributions are welcome! |
| 83 | + |
| 84 | +## License |
| 85 | + |
| 86 | +ISC |
0 commit comments