How lemos1235/excel-translator works
Project Type and Purpose
• This is a desktop translation tool written in Go, offering both CLI and GUI front-end options to translate Japanese text in Excel (and Word) documents into Simplified Chinese.
• It reads files, preserves formatting, invokes an AI translation service (via API), and writes back the translated documents.
File Structure Analysis
• Top-level:
• cli/ – Command-line front end (cli/main.go)
• gui2/ – GUI front end (gui2/gui2.go)
• core/ – Core orchestration logic (core/core.go)
• word/ – Word document translator
• config/ – Configuration loader and model for TOML settings
• demo/ – Sample/demo inputs
• main.go – Likely the default entry point (could route to CLI or GUI)
• Makefile – Build and install targets
• go.mod, go.sum – Dependency management
Insights from README
• Two modes of operation: CLI and GUI (built with miqt).
• A TOML config file drives concurrency, CJK filtering, prompt templates, and LLM API parameters.
• Workflow: load file → parse relevant text nodes → call LLM API → inject translations → save file.
a. Main Components
1) Front Ends
• CLI component
• GUI component
2) Core Translator Service
3) Configuration Loader
4) File Parsers/Translators
– Word translator
5) External LLM API
6) File I/O (read/write)
b. Relationships & Data Flows
1) User invokes CLI or GUI → triggers Core
2) Core calls Configuration Loader → obtains settings
3) Core invokes File Parsers for each document type → yields text segments
4) Core batches segments (per max_concurrent_requests) → sends to External LLM API
5) Receives translated text → File Parsers recompose document preserving formatting
6) Core writes output file
c. Architectural Patterns & Principles
• Separation of Concerns: front ends vs. core engine vs. parsers
• Strategy Pattern: interchangeable parsers for Excel vs. Word
• Adapter Pattern: wrapper around LLM API to standardize calls
• Concurrency Control: managed by configuration (max_concurrent_requests)
d. Key Technologies
• Go modules (go.mod)
• miqt for GUI
• toml for config
• External HTTP API for LLM model