How ao-chii/nextranslation works
Project type and purpose
• From the file tree (“src/nex_translation”) and the README title “NexTranslation,” this is a Python-based document translation application.
• It provides both a CLI and a GUI front end, reads input documents (PDFs), processes them, sends text to an external translator (Google Translate), and renders translated output.
File structure
• Top-level artifacts:
• pyproject.toml (build & dependency manager)
• config.json (runtime configuration)
• docs/ (design docs, layered architecture description)
• src/nex_translation/ (application code)
• tests/ (unit tests and sample PDFs)
• Within src/nex_translation the code is organized by layers:
• presentation/ (cli.py, gui.py)
• core/ (converter.py, doclayout.py, pdf_processor.py, pdfinterpreter.py, translator.py, google_translator.py)
• infrastructure/ (cache.py, config.py)
• utils/ (exceptions.py, logger.py)
README and docs
• README is minimal, but docs/LayeredAchitecture.md and docs/layer_architecture.md confirm a classic layered architecture model.
– Presentation layer: CLI module and GUI module
– Core / Business Logic layer:
· PDFInterpreter (parses PDFs into text & structure)
· PDFProcessor (extracts pages, images, text blocks)
· Converter & DocLayout (rebuilds translated text into PDF layout)
· Translator (orchestrates translation workflow)
· GoogleTranslator (wraps calls to Google Translate API)
– Infrastructure layer:
· Config (reads config.json)
· Cache (stores intermediate translations for performance)
– Utilities:
· Logger (centralized logging)
· Exception handlers
– External services: Google Translate API
– Data stores (if any): local cache store on disk
– Presentation → Core.Translator.start()
– Translator → PDFInterpreter → PDFProcessor → returns document model
– Translator → GoogleTranslator (with caching via Infrastructure.Cache)
– Translator → Converter/DocLayout → writes output file
– All layers may call Utils.Logger/Exceptions
– Config is read at startup and injected into all layers
c. Architectural patterns and principles:
– Layered architecture (Presentation, Core, Infrastructure, Utils)
– Dependency inversion: Core not tied directly to CLI/GUI or to cache implementation
– Single Responsibility: each module has a well-defined role
– Externalized configuration (config.json) and caching for idempotent external API calls
d. Key technologies and frameworks:
– Python 3 (pyproject.toml)
– CLI argument parsing (in cli.py)
– GUI toolkit (as implemented in gui.py)
– Google Translate REST API
– PDF parsing library (pdfinterpreter.py likely wraps a third-party lib)
– Logging and exception utilities