How nextai-translator/nextai-translator works
NextAI Translator is a cross-platform translation and writing assistant delivered as a browser extension and a Tauri desktop app. Users submit selected or entered text, then use translation, polishing, or summarization, with results supporting streaming and speech; screenshot translation is a separate desktop path. Shared components provide provider-specific LLM requests, settings, language support, and persisted history and vocabulary. The README documents additional capabilities and providers beyond the sampled code; those branches are shown where useful, but unsampled implementation links are left unverified.
Main entry points: Translator.tsx Translator interface · App.tsx Desktop window router · Window.tsx Window shell · ocr.rs Screenshot OCR
Components 25
User interfaces
- Browser extension UI
src/browser-extension/content_script/index.tsx - Extension background
src/browser-extension/background/index.ts - Translator interface
src/common/components/Translator.tsx - Settings
src/common/components/Settings.tsx - Custom actions
src/common/components/ActionManager.tsx
Desktop runtime
- Desktop window router
src/tauri/App.tsx - Window shell
src/tauri/components/Window.tsx - Screenshot OCR
src-tauri/src/ocr.rs - Native window control
src-tauri/src/windows.rs - Text insertion
src-tauri/src/insertion.rs - Writing assistance
src-tauri/src/writing.rs - Desktop configuration
src-tauri/src/config.rs - Tauri command bindings
src/tauri/bindings.ts
Language services
- Translation orchestration
src/common/translate.ts - LLM request engine
src/common/engines/abstract-openai.ts - Provider engines
src/common/engines - Language catalog
src/common/lang/index.ts - Text to speech
src/common/tts/index.ts
User data
- Settings access
src/common/hooks/useSettings.ts - Theme access
src/common/hooks/useTheme.ts - Translation history
src/common/internal-services/history.ts - Vocabulary book
src/common/internal-services/vocabulary.ts
External services
- LLM providers
- Speech service
Other components
- User
Connections 26
- User → Browser extension UI: selects text
README.md - Browser extension UI → Translator interface: renders
src/browser-extension/content_script/index.tsx - Extension background → Translation history: uses service
src/browser-extension/background/index.ts - Extension background → Vocabulary book: uses service
src/browser-extension/background/index.ts - User → Desktop window router: opens desktop
README.md - Desktop window router → Window shell: routes windows
src/tauri/App.tsx - Window shell → Theme access: reads theme
src/tauri/components/Window.tsx - Window shell → Tauri command bindings: invokes commands
src/tauri/components/Window.tsx - Translator interface → Translation orchestration: requests translation
- Translation orchestration → LLM request engine: requests completion
- LLM request engine → Provider engines: dispatches requests
src/common/engines/openrouter.ts - Provider engines → LLM providers: calls provider
- Settings → Settings access: reads settings
- Settings access → Desktop configuration: loads desktop config
- Translator interface → Language catalog: selects language
- Translator interface → Text to speech: speaks results
- Text to speech → Speech service: synthesizes speech
- User → Screenshot OCR: requests screenshot translation
- Screenshot OCR → Text insertion: inserts recognized text
src-tauri/src/ocr.rs - Screenshot OCR → Native window control: uses windows
src-tauri/src/ocr.rs - Desktop window router → Native window control: creates windows
- User → Custom actions: configures actions
- Custom actions → Translation history: stores history
- User → Writing assistance: requests polishing
- User → Translation history: reviews translations
README.md - User → Vocabulary book: collects words
README.md