Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
feat(engines): add offline local AI document translation via Ollama
return {name:"chinchi-codes"}9ede568ec9a0
diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 57dd00fe..a097d7e4 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -1805,3 +1805,17 @@ Transcription runs entirely locally and offline on your computer; no audio or daformats requires FFmpeg. FFmpeg must be installed (via Settings → *Engines*, bundled, or found on `PATH`).- **Languages**: Whisper supports auto-detection (`auto`) as well as specific language codes (`-l <code>`, e.g. `hi` forHindi, `en` for English, `es` for Spanish, `fr` for French, `ja` for Japanese, `zh` for Chinese).++## Document & Book Translator (Offline AI)++Filee translates documents, books, and text files (.pdf, .docx, .epub, .md, .txt, .hwpx, .srt) locally using Ollama or local offline models. Translation runs entirely on the user's computer: no text or document data is ever uploaded or sent to third-party web services.++- **Offline privacy**: Adheres strictly to Filee's offline promise: "Filee converts files on your own computer and never uploads them." Works with Ollama running locally (`http://localhost:11434`) or bundled offline models. Cloud-forwarded models (`*-cloud`) are refused with a security warning to ensure privacy.+- **Where it lives**:+ - Available as the **Translate** preset in Settings → *Presets*, where the target language (e.g. English, Spanish, Hindi, French, German, Chinese, Japanese, etc.) is configured as the single source of truth.+ - Sits cleanly on the back face (`BackPresetIds`) of document and text profiles for fresh installs, keeping front faces clean and untouched (#806 compliance).+ - Configurable in Settings → *Engines* under **Translator (Offline AI)** with direct controls to manage local models, pull offline models, and start/stop the local Ollama server without requiring manual terminal commands.+- **Format and layout preservation**:+ - **DOCX & HWPX**: The document XML AST structure is parsed into paragraphs, runs, and tables. Headings, font sizes, margins, bullet lists, bold/italic markup, images, and hyperlinks are preserved; only text runs are translated in place.+ - **PDF**: The high-fidelity document layout pipeline translates structured text blocks in place and renders them preserving page dimensions, font metrics, margins, and layout flow without clipping or file corruption.+ - **Markdown, Plain text & Subtitles**: Source formatting, code blocks, tables, and subtitle timing cues (`00:01:20,000 --> 00:01:23,000`) are preserved.diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.jsonindex 4d89df20..0f263ef5 100644--- a/src/Filee.App/Assets/i18n/ar.json+++ b/src/Filee.App/Assets/i18n/ar.json@@ -1271,5 +1271,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/de.json b/src/Filee.App/Assets/i18n/de.jsonindex 23e57ebc..dee67298 100644--- a/src/Filee.App/Assets/i18n/de.json+++ b/src/Filee.App/Assets/i18n/de.json@@ -1270,5 +1270,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex c24a2de0..3a1ac2c2 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.jsonindex c672c7e9..b2f6e1ba 100644--- a/src/Filee.App/Assets/i18n/es.json+++ b/src/Filee.App/Assets/i18n/es.json@@ -1272,5 +1272,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/fr.json b/src/Filee.App/Assets/i18n/fr.jsonindex 7542f9e9..6d6eaa3d 100644--- a/src/Filee.App/Assets/i18n/fr.json+++ b/src/Filee.App/Assets/i18n/fr.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.jsonindex fc1be047..b8230ebb 100644--- a/src/Filee.App/Assets/i18n/hi.json+++ b/src/Filee.App/Assets/i18n/hi.json@@ -1272,5 +1272,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/id.json b/src/Filee.App/Assets/i18n/id.jsonindex 49e2bfd6..10e4e583 100644--- a/src/Filee.App/Assets/i18n/id.json+++ b/src/Filee.App/Assets/i18n/id.json@@ -1270,5 +1270,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/it.json b/src/Filee.App/Assets/i18n/it.jsonindex 982e035c..52e99721 100644--- a/src/Filee.App/Assets/i18n/it.json+++ b/src/Filee.App/Assets/i18n/it.json@@ -1270,5 +1270,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.jsonindex 3ff6150e..7ac10a5f 100644--- a/src/Filee.App/Assets/i18n/ja.json+++ b/src/Filee.App/Assets/i18n/ja.json@@ -1272,5 +1272,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 5155834a..1ea86764 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/ne.json b/src/Filee.App/Assets/i18n/ne.jsonindex 64721b64..d532f011 100644--- a/src/Filee.App/Assets/i18n/ne.json+++ b/src/Filee.App/Assets/i18n/ne.json@@ -1272,5 +1272,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.jsonindex c5b73494..bc047b68 100644--- a/src/Filee.App/Assets/i18n/pl.json+++ b/src/Filee.App/Assets/i18n/pl.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.jsonindex 4cb13284..0d3abe4e 100644--- a/src/Filee.App/Assets/i18n/pt-BR.json+++ b/src/Filee.App/Assets/i18n/pt-BR.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/pt-PT.json b/src/Filee.App/Assets/i18n/pt-PT.jsonindex c5f5deba..4565937f 100644--- a/src/Filee.App/Assets/i18n/pt-PT.json+++ b/src/Filee.App/Assets/i18n/pt-PT.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.jsonindex 911d72da..a2f93e99 100644--- a/src/Filee.App/Assets/i18n/ru.json+++ b/src/Filee.App/Assets/i18n/ru.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/th.json b/src/Filee.App/Assets/i18n/th.jsonindex 42c9c874..8e249458 100644--- a/src/Filee.App/Assets/i18n/th.json+++ b/src/Filee.App/Assets/i18n/th.json@@ -1272,5 +1272,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/tr.json b/src/Filee.App/Assets/i18n/tr.jsonindex f7fa83e0..f9f98e4e 100644--- a/src/Filee.App/Assets/i18n/tr.json+++ b/src/Filee.App/Assets/i18n/tr.json@@ -1270,5 +1270,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 0986c0da..e11f5b0d 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "直接复制文件和文件夹,不转换格式。原件保留,重名时自动编号。","presets.copy_choose_folder": "请选择目标文件夹,或选择“每次询问”。","presets.copy_back": "复制到文件夹放在背面,请切换到背面后添加。",- "presets.copy_action": "操作"+ "presets.copy_action": "操作",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Assets/i18n/zh-TW.json b/src/Filee.App/Assets/i18n/zh-TW.jsonindex 7dc954fc..91918331 100644--- a/src/Filee.App/Assets/i18n/zh-TW.json+++ b/src/Filee.App/Assets/i18n/zh-TW.json@@ -1292,5 +1292,45 @@"presets.copy_hint": "Copy files and folders without conversion. Originals stay where they are; existing names get a number.","presets.copy_choose_folder": "Choose a destination folder, or Ask every time.","presets.copy_back": "Copy to folder belongs on the back face. Switch to Back to add it.",- "presets.copy_action": "Action"+ "presets.copy_action": "Action",+ "preset.translate": "Translate",+ "preset.translate.donut": "Translate",+ "preset.translate_label": "Translate content",+ "preset.translate_target_language": "Target language",+ "presets.group.translate": "Translate",+ "presets.translate_content": "Translate document",+ "presets.translate_hint": "Translates the document or book into the target language on your computer.",+ "presets.target_language": "Target language",+ "engines.package.translator.name": "Translator (Offline AI)",+ "engines.package.translator.description": "Translates documents and books locally on your PC without uploading them. Works offline using local Ollama or bundled models.",+ "engines.package.translator.sizes": "Offline Local AI · http://127.0.0.1:11434",+ "engines.package.translator.no_model": "Ollama is running at http://127.0.0.1:11434 with no models found. Pull an offline model like llama3.2.",+ "engines.package.translator.not_running": "Ollama is installed on this computer, but not running. Start Ollama from Manage Models.",+ "engines.package.translator.cloud_skipped": "{0} cloud model(s) were hidden to ensure document text never leaves your PC.",+ "engines.package.translator.only_cloud_models": "Only cloud models were found. Cloud models (-cloud) send text to ollama.com and are blocked. Please pull a local offline model.",+ "engines.guidance.windows.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your PC.",+ "engines.guidance.macos.translator": "To use offline translation:\n1. Download Ollama: https://ollama.com/download (or brew install ollama)\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your Mac.",+ "engines.guidance.linux.translator": "To use offline translation:\n1. Install Ollama: curl -fsSL https://ollama.com/install.sh | sh\n2. Run in terminal: ollama pull llama3.2 (or any model: qwen2.5, mistral...)\n3. Filee listens offline at http://127.0.0.1:11434 — zero document text ever leaves your computer.",+ "engines.ollama.manage": "Manage Ollama",+ "engines.ollama.manage_hint": "Manage local Ollama models, start/stop server, and install offline models",+ "engines.ollama.title": "Ollama Local AI Management",+ "engines.ollama.description": "All models run 100% offline on your computer. Cloud-forwarded models (-cloud) are blocked for document privacy.",+ "engines.ollama.server_running": "Server Running",+ "engines.ollama.server_stopped": "Server Stopped",+ "engines.ollama.start_server": "Start Ollama Server",+ "engines.ollama.stop_server": "Stop Ollama Server",+ "engines.ollama.refresh": "Refresh",+ "engines.ollama.pull_title": "Install / Pull Offline Model",+ "engines.ollama.pull_button": "Pull Model",+ "engines.ollama.pull_placeholder": "Model tag (e.g. llama3.2, qwen2.5:3b, mistral)",+ "engines.ollama.cloud_warning": "Cloud models (-cloud) forward document text over the internet and are blocked. Please enter a local offline model.",+ "engines.ollama.installed_models": "Downloaded Models",+ "engines.ollama.no_models": "No models found in Ollama. Enter a model tag above and click Pull Model.",+ "engines.ollama.use_model": "Use Model",+ "engines.ollama.using_model": "Active Model (Using Now)",+ "engines.ollama.cloud_blocked": "Cloud Model (Blocked)",+ "engines.ollama.offline_badge": "Offline Local",+ "engine.reason.download_translator": "Requires local Ollama at http://127.0.0.1:11434 (see Settings → Engines)",+ "error.translation_needs_engine": "Offline translation requires local Ollama (http://127.0.0.1:11434). Check Settings → Engines for setup instructions.",+ "error.translation_cloud_model_forbidden": "Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer."}diff --git a/src/Filee.App/Services/EngineDownloadService.cs b/src/Filee.App/Services/EngineDownloadService.csindex d8572332..36d67ab6 100644--- a/src/Filee.App/Services/EngineDownloadService.cs+++ b/src/Filee.App/Services/EngineDownloadService.cs@@ -40,12 +40,29 @@ public sealed partial class EnginePackageState : ObservableObjectpublic string Name => _loc[$"engines.package.{Package.Id}.name"];/// <summary>Whether the package card has a Settings button (LibreOffice: which conversions to PDF it takes over).</summary>- public bool HasSettings => Package.Id == "libreoffice";+ public bool HasSettings => Package.Id is "libreoffice" or "translator";++ public string SettingsLabel => Package.Id == "translator"++ ? (_loc["engines.ollama.manage"] != "engines.ollama.manage" ? _loc["engines.ollama.manage"] : "Manage Ollama")++ : (_loc["engines.settings"] != "engines.settings" ? _loc["engines.settings"] : "Settings");++ public string SettingsTooltip => Package.Id == "translator"++ ? (_loc["engines.ollama.manage_hint"] != "engines.ollama.manage_hint" ? _loc["engines.ollama.manage_hint"] : "Manage local Ollama models, start/stop server, and install offline models")++ : (_loc["engines.lo_title"] != "engines.lo_title" ? _loc["engines.lo_title"] : "LibreOffice options");public string Description => _loc[$"engines.package.{Package.Id}.description"];- public string Sizes => EngineDownloads.CanDownload(Package)- ? _loc.Format("engines.package.size", FormatBytes(EngineDownloads.DownloadSize(Package)), FormatBytes(Package.InstalledSize))- : _loc["engines.package.system_required"];+ public bool IsTranslator => Package.Id == "translator";+ public bool IsLibreOffice => Package.Id == "libreoffice";++ public string Sizes => Package.Id == "translator"+ ? _loc["engines.package.translator.sizes"]+ : EngineDownloads.CanDownload(Package)+ ? _loc.Format("engines.package.size", FormatBytes(EngineDownloads.DownloadSize(Package)), FormatBytes(Package.InstalledSize))+ : _loc["engines.package.system_required"];/// <summary>/// How to get an engine Filee doesn't download on this system (FFmpeg and Ghostscript from Homebrew on macOS,@@ -215,9 +232,13 @@ public sealed class EngineDownloadService/// In the order the engines look: the user's own copy, Filee's download, a copy on the PC. A copy Filee didn't/// download gets its version checked in the background (<see cref="EnginePackageState.UpdateNote"/>)./// </summary>+ private static readonly HttpClient SharedOllamaClient = new() { Timeout = TimeSpan.FromMilliseconds(250) };+private EnginePackageStatus StatusOf(EnginePackageState state){var id = state.Package.Id;+ if (id == "translator")+ return StatusOfTranslator(state);var own = EngineEnvironment.OwnCopyFolder(id);var system = own is null && !_installer.IsInstalled(state.Package) ? EngineEnvironment.SystemCopyFolder(id) : null;state.OwnCopyFolder = own ?? system;@@ -243,6 +264,183 @@ public sealed class EngineDownloadService}/// <summary>Filee's downloads that have a newer version now (only engines the user installed).</summary>+++ private EnginePackageStatus StatusOfTranslator(EnginePackageState state)++ {++ var id = state.Package.Id;++ var own = EngineEnvironment.OwnCopyFolder(id);++ var system = own is null && !_installer.IsInstalled(state.Package) ? EngineEnvironment.SystemCopyFolder(id) : null;++ state.OwnCopyFolder = own ?? system;++ state.FromSystem = system is not null;++ state.UpdateNote = null;++ state.IsOutdated = false;++++ _ = CheckOllamaAsync(state);++++ return state.OwnCopyFolder is not null ? EnginePackageStatus.OwnCopy++ : _installer.IsInstalled(state.Package) ? EnginePackageStatus.Installed++ : EnginePackageStatus.NotInstalled;++ }++++ private async Task CheckOllamaAsync(EnginePackageState state)++ {++ try++ {++ using var response = await SharedOllamaClient.GetAsync("http://127.0.0.1:11434/api/tags");++ if (response.IsSuccessStatusCode)++ {++ using var stream = await response.Content.ReadAsStreamAsync();++ using var doc = await System.Text.Json.JsonDocument.ParseAsync(stream);++ int totalCount = 0;++ int cloudCount = 0;++ int localCount = 0;++++ if (doc.RootElement.TryGetProperty("models", out var models) && models.ValueKind == System.Text.Json.JsonValueKind.Array)++ {++ foreach (var m in models.EnumerateArray())++ {++ var name = m.TryGetProperty("name", out var n) ? n.GetString() : null;++ if (string.IsNullOrWhiteSpace(name)) continue;++ totalCount++;++ if (Filee.Engines.Translation.TranslationService.IsCloudModel(name))++ cloudCount++;++ else++ localCount++;++ }++ }++++ await Dispatcher.UIThread.InvokeAsync(() =>++ {++ if (localCount > 0)++ {++ state.Status = EnginePackageStatus.OwnCopy;++ state.OwnCopyFolder ??= "http://127.0.0.1:11434 (Local Ollama)";++ state.UpdateNote = cloudCount > 0++ ? _loc.Format("engines.package.translator.cloud_skipped", cloudCount)++ : null;++ }++ else if (totalCount > 0 && cloudCount == totalCount)++ {++ state.Status = EnginePackageStatus.NotInstalled;++ state.UpdateNote = _loc["engines.package.translator.only_cloud_models"];++ }++ else++ {++ state.Status = EnginePackageStatus.NotInstalled;++ state.UpdateNote = _loc["engines.package.translator.no_model"];++ }++ });++ return;++ }++ }++ catch++ {++ // Ollama not reachable++ }++++ var ollamaExe = EngineEnvironment.SystemProgram("ollama", "ollama.exe");++ if (ollamaExe is not null)++ {++ await Dispatcher.UIThread.InvokeAsync(() =>++ {++ if (state.Status != EnginePackageStatus.OwnCopy)++ {++ state.Status = EnginePackageStatus.NotInstalled;++ state.UpdateNote = _loc["engines.package.translator.not_running"];++ }++ });++ }++ }++++public IReadOnlyList<EnginePackageState> Outdated => Packages.Where(p => p.CanUpdate).ToList();/// <summary>diff --git a/src/Filee.App/ViewModels/OllamaModelManagerViewModel.cs b/src/Filee.App/ViewModels/OllamaModelManagerViewModel.csnew file mode 100644index 00000000..18a57b77--- /dev/null+++ b/src/Filee.App/ViewModels/OllamaModelManagerViewModel.cs@@ -0,0 +1,374 @@+using System.Collections.ObjectModel;+using System.Diagnostics;+using System.Net.Http.Json;+using System.Text.Json;+using Avalonia.Threading;+using CommunityToolkit.Mvvm.ComponentModel;+using CommunityToolkit.Mvvm.Input;+using Filee.App.Services;+using Filee.Core.Localization;+using Filee.Core.Settings;+using Filee.Engines.Infrastructure;+using Filee.Engines.Translation;++namespace Filee.App.ViewModels;++public sealed partial class OllamaModelItem : ObservableObject+{+ public string Name { get; init; } = "";+ public string SizeFormatted { get; init; } = "";+ public bool IsCloud { get; init; }++ [ObservableProperty]+ private bool _isUsing;++ [ObservableProperty]+ private string _actionText = "Use";++ [ObservableProperty]+ private bool _isActionEnabled = true;+}++public sealed partial class OllamaModelManagerViewModel : ObservableObject+{+ private static readonly Uri OllamaBase = new("http://127.0.0.1:11434");+ private readonly ILocalizer _loc;+ private readonly UserDataStore _store;++ public OllamaModelManagerViewModel()+ : this(AppHost.Get<ILocalizer>(), AppHost.Get<UserDataStore>())+ {+ }++ public OllamaModelManagerViewModel(ILocalizer loc, UserDataStore store)+ {+ _loc = loc;+ _store = store;+ _activeModelName = store.Settings.PreferredOllamaModel ?? TranslationService.ActiveOllamaModel ?? "";+ _ = RefreshStatusAsync();+ }++ [ObservableProperty]+ private bool _isOllamaInstalled;++ [ObservableProperty]+ private bool _isServerRunning;++ [ObservableProperty]+ private string _serverStatusText = "";++ [ObservableProperty]+ private ObservableCollection<OllamaModelItem> _models = [];++ [ObservableProperty]+ private string _newModelName = "";++ [ObservableProperty]+ private bool _isCloudWarningVisible;++ [ObservableProperty]+ private bool _canPull;++ [ObservableProperty]+ private bool _isPulling;++ [ObservableProperty]+ private double _pullProgress;++ [ObservableProperty]+ private string _pullStatusText = "";++ [ObservableProperty]+ private string _activeModelName = "";++ partial void OnNewModelNameChanged(string value)+ {+ var trimmed = value.Trim();+ if (string.IsNullOrWhiteSpace(trimmed))+ {+ IsCloudWarningVisible = false;+ CanPull = false;+ return;+ }++ var isCloud = TranslationService.IsCloudModel(trimmed);+ IsCloudWarningVisible = isCloud;+ CanPull = !isCloud && !IsPulling && IsServerRunning;+ }++ partial void OnIsServerRunningChanged(bool value)+ {+ OnNewModelNameChanged(NewModelName);+ }++ [RelayCommand]+ public async Task RefreshStatusAsync()+ {+ IsOllamaInstalled = CheckIsOllamaInstalled();+ await CheckServerAndLoadModelsAsync();+ }++ private static bool CheckIsOllamaInstalled()+ {+ if (EngineEnvironment.SystemProgram("ollama", "ollama.exe") is not null)+ return true;++ if (OperatingSystem.IsWindows())+ {+ var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);+ if (File.Exists(Path.Combine(localAppData, "Programs", "Ollama", "ollama.exe")))+ return true;+ }+ return false;+ }++ private async Task CheckServerAndLoadModelsAsync()+ {+ try+ {+ using var client = new HttpClient { Timeout = TimeSpan.FromMilliseconds(500) };+ using var response = await client.GetAsync(new Uri(OllamaBase, "/api/tags"));+ if (response.IsSuccessStatusCode)+ {+ IsServerRunning = true;+ ServerStatusText = $"{_loc["engines.ollama.server_running"]} (http://127.0.0.1:11434)";++ using var stream = await response.Content.ReadAsStreamAsync();+ using var doc = await JsonDocument.ParseAsync(stream);++ var list = new List<OllamaModelItem>();+ if (doc.RootElement.TryGetProperty("models", out var arr) && arr.ValueKind == JsonValueKind.Array)+ {+ foreach (var m in arr.EnumerateArray())+ {+ var name = m.TryGetProperty("name", out var n) ? n.GetString() : null;+ if (string.IsNullOrWhiteSpace(name)) continue;++ long size = m.TryGetProperty("size", out var s) && s.TryGetInt64(out var sz) ? sz : 0;+ var sizeStr = size > 0 ? $"{size / 1_000_000_000.0:0.1} GB" : "";+ var isCloud = TranslationService.IsCloudModel(name);+ var isUsing = !isCloud && string.Equals(name, ActiveModelName, StringComparison.OrdinalIgnoreCase);++ list.Add(new OllamaModelItem+ {+ Name = name,+ SizeFormatted = sizeStr,+ IsCloud = isCloud,+ IsUsing = isUsing,+ ActionText = isCloud ? _loc["engines.ollama.cloud_blocked"] : isUsing ? _loc["engines.ollama.using_model"] : _loc["engines.ollama.use_model"],+ IsActionEnabled = !isCloud && !isUsing+ });+ }+ }++ if (string.IsNullOrWhiteSpace(ActiveModelName) && list.FirstOrDefault(m => !m.IsCloud) is { } firstLocal)+ {+ firstLocal.IsUsing = true;+ firstLocal.ActionText = _loc["engines.ollama.using_model"];+ firstLocal.IsActionEnabled = false;+ ActiveModelName = firstLocal.Name;+ TranslationService.ActiveOllamaModel = firstLocal.Name;+ }++ Models = new ObservableCollection<OllamaModelItem>(list);+ return;+ }+ }+ catch+ {+ // Server not running+ }++ IsServerRunning = false;+ ServerStatusText = _loc["engines.ollama.server_stopped"];+ Models = [];+ }++ [RelayCommand]+ public async Task UseModelAsync(OllamaModelItem item)+ {+ if (item.IsCloud || item.IsUsing)+ return;++ item.ActionText = "Starting...";+ item.IsActionEnabled = false;++ foreach (var m in Models)+ {+ if (m != item && m.IsUsing)+ {+ m.IsUsing = false;+ m.ActionText = m.IsCloud ? _loc["engines.ollama.cloud_blocked"] : _loc["engines.ollama.use_model"];+ m.IsActionEnabled = !m.IsCloud;+ }+ }++ try+ {+ // Warm up model via Ollama local API+ using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(15) };+ var warmupBody = new { model = item.Name, prompt = "", stream = false };+ _ = await client.PostAsJsonAsync(new Uri(OllamaBase, "/api/generate"), warmupBody);+ }+ catch+ {+ // Ignore warmup failures+ }++ ActiveModelName = item.Name;+ TranslationService.ActiveOllamaModel = item.Name;+ _store.Settings.PreferredOllamaModel = item.Name;+ _store.SaveSettings();++ item.IsUsing = true;+ item.ActionText = _loc["engines.ollama.using_model"];+ item.IsActionEnabled = false;+ }++ [RelayCommand]+ public async Task StopServerAsync()+ {+ try+ {+ if (OperatingSystem.IsWindows())+ {+ var psi = new ProcessStartInfo+ {+ FileName = "powershell",+ Arguments = "-NoProfile -Command \"Get-Process *ollama* -ErrorAction SilentlyContinue | Stop-Process -Force\"",+ CreateNoWindow = true,+ UseShellExecute = false+ };+ using var p = Process.Start(psi);+ if (p is not null)+ await p.WaitForExitAsync();+ }+ else+ {+ var psi = new ProcessStartInfo+ {+ FileName = "pkill",+ Arguments = "-f ollama",+ CreateNoWindow = true,+ UseShellExecute = false+ };+ using var p = Process.Start(psi);+ if (p is not null)+ await p.WaitForExitAsync();+ }+ }+ catch { }++ await Task.Delay(300);+ await RefreshStatusAsync();+ }++ [RelayCommand]+ public async Task StartServerAsync()+ {+ try+ {+ var exe = EngineEnvironment.SystemProgram("ollama", "ollama.exe")+ ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Programs", "Ollama", "ollama.exe");++ var psi = new ProcessStartInfo+ {+ FileName = File.Exists(exe) ? exe : "ollama",+ Arguments = "serve",+ CreateNoWindow = true,+ UseShellExecute = false+ };+ Process.Start(psi);+ }+ catch { }++ // Poll for up to 5 seconds+ for (int i = 0; i < 10; i++)+ {+ await Task.Delay(500);+ try+ {+ using var client = new HttpClient { Timeout = TimeSpan.FromMilliseconds(300) };+ var res = await client.GetAsync(new Uri(OllamaBase, "/api/tags"));+ if (res.IsSuccessStatusCode)+ break;+ }+ catch { }+ }++ await RefreshStatusAsync();+ }++ [RelayCommand]+ public async Task PullModelAsync()+ {+ var model = NewModelName.Trim();+ if (string.IsNullOrWhiteSpace(model) || TranslationService.IsCloudModel(model))+ return;++ IsPulling = true;+ CanPull = false;+ PullProgress = 0;+ PullStatusText = "Connecting...";++ try+ {+ using var client = new HttpClient { Timeout = TimeSpan.FromHours(1) };+ var request = new HttpRequestMessage(HttpMethod.Post, new Uri(OllamaBase, "/api/pull"))+ {+ Content = JsonContent.Create(new { name = model, stream = true })+ };++ using var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);+ response.EnsureSuccessStatusCode();++ using var stream = await response.Content.ReadAsStreamAsync();+ using var reader = new StreamReader(stream);++ while (await reader.ReadLineAsync() is { } line)+ {+ if (string.IsNullOrWhiteSpace(line)) continue;++ try+ {+ using var doc = JsonDocument.Parse(line);+ var status = doc.RootElement.TryGetProperty("status", out var s) ? s.GetString() : "";+ long total = doc.RootElement.TryGetProperty("total", out var t) && t.TryGetInt64(out var tot) ? tot : 0;+ long completed = doc.RootElement.TryGetProperty("completed", out var c) && c.TryGetInt64(out var comp) ? comp : 0;++ if (total > 0 && completed > 0)+ {+ var pct = (double)completed / total * 100.0;+ PullProgress = Math.Min(100, Math.Max(0, pct));+ PullStatusText = $"{status} ({PullProgress:0}%)";+ }+ else if (!string.IsNullOrWhiteSpace(status))+ {+ PullStatusText = status;+ }+ }+ catch { }+ }++ PullProgress = 100;+ PullStatusText = "Complete!";+ NewModelName = "";+ await Task.Delay(500);+ await CheckServerAndLoadModelsAsync();++ if (Models.FirstOrDefault(m => string.Equals(m.Name, model, StringComparison.OrdinalIgnoreCase)) is { } newlyDownloaded)+ {+ await UseModelAsync(newlyDownloaded);+ }+ }+ catch (Exception ex)+ {+ PullStatusText = $"Error: {ex.Message}";+ }+ finally+ {+ IsPulling = false;+ OnNewModelNameChanged(NewModelName);+ }+ }+}diff --git a/src/Filee.App/ViewModels/PresetEditorViewModel.cs b/src/Filee.App/ViewModels/PresetEditorViewModel.csindex 916946e8..1620c7c7 100644--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs@@ -172,6 +172,27 @@ public sealed partial class PresetEditorViewModel : ObservableObject_caption = _edit.Media.Caption;_spokenLanguage = SpokenLanguageChoices.FirstOrDefault(l => string.Equals(l.Value, _edit.Media.SpokenLanguage, StringComparison.OrdinalIgnoreCase))?? SpokenLanguageChoices[0];+ TranslationLanguageChoices =+ [+ new Choice<string>("en", "English"),+ new Choice<string>("es", "Spanish (Español)"),+ new Choice<string>("fr", "French (Français)"),+ new Choice<string>("de", "German (Deutsch)"),+ new Choice<string>("zh", "Chinese (中文)"),+ new Choice<string>("hi", "Hindi (हिन्दी)"),+ new Choice<string>("ja", "Japanese (日本語)"),+ new Choice<string>("ko", "Korean (한국어)"),+ new Choice<string>("ru", "Russian (Русский)"),+ new Choice<string>("pt", "Portuguese (Português)"),+ new Choice<string>("ar", "Arabic (العربية)"),+ new Choice<string>("it", "Italian (Italiano)"),+ new Choice<string>("nl", "Dutch (Nederlands)"),+ new Choice<string>("pl", "Polish (Polski)"),+ new Choice<string>("tr", "Turkish (Türkçe)"),+ new Choice<string>("ne", "Nepali (नेपाली)")+ ];+ _targetLanguage = TranslationLanguageChoices.FirstOrDefault(l => string.Equals(l.Value, _edit.Translate.TargetLanguage, StringComparison.OrdinalIgnoreCase))+ ?? TranslationLanguageChoices[0];_archiveLevel = ArchiveLevels.First(l => l.Value == _edit.Archive.Level);_combineIntoOne = _edit.Archive.CombineIntoOne;_saveEveryFrame = _edit.Media.SaveEveryFrame;@@ -258,6 +279,12 @@ public sealed partial class PresetEditorViewModel : ObservableObject/// <summary>The spoken languages Whisper recognizes (MediaOptions.SpokenLanguage), Auto first.</summary>public IReadOnlyList<Choice<string>> SpokenLanguageChoices { get; }+ public IReadOnlyList<Choice<string>> TranslationLanguageChoices { get; }++ [ObservableProperty] private Choice<string> _targetLanguage;++ public bool ShowTranslate => _original.Id == "translate" || _edit.Translate.Enabled;+/// <summary>What "Recognize text" needs: Tesseract, or on a Mac Apple Vision (Tesseract only for other languages).</summary>public string OcrHint { get; }diff --git a/src/Filee.App/Views/OllamaModelManagerWindow.axaml b/src/Filee.App/Views/OllamaModelManagerWindow.axamlnew file mode 100644index 00000000..965d253c--- /dev/null+++ b/src/Filee.App/Views/OllamaModelManagerWindow.axaml@@ -0,0 +1,165 @@+<Window xmlns="https://github.com/avaloniaui"+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"+ xmlns:vm="using:Filee.App.ViewModels"+ x:Class="Filee.App.Views.OllamaModelManagerWindow"+ x:DataType="vm:OllamaModelManagerViewModel"+ Title="{DynamicResource engines.ollama.title}"+ Icon="avares://Filee/Assets/Icons/filee.ico"+ Width="640"+ Height="620"+ MinWidth="540"+ MinHeight="480"+ WindowStartupLocation="CenterOwner"+ ShowInTaskbar="False">+ <Grid RowDefinitions="Auto,*,Auto" Margin="22">+ <!-- Header -->+ <StackPanel Grid.Row="0" Spacing="10" Margin="0,0,0,14">+ <StackPanel Spacing="4">+ <TextBlock Classes="h2" Text="{DynamicResource engines.ollama.title}" />+ <TextBlock Classes="caption" TextWrapping="Wrap" Text="{DynamicResource engines.ollama.description}" />+ </StackPanel>++ <!-- Server Status & Actions -->+ <Border Classes="card" Padding="14,10">+ <DockPanel LastChildFill="True">+ <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Spacing="8">+ <Button Content="{DynamicResource engines.ollama.stop_server}" IsVisible="{Binding IsServerRunning}"+ Command="{Binding StopServerCommand}" />+ <Button Classes="accent" Content="{DynamicResource engines.ollama.start_server}" IsVisible="{Binding !IsServerRunning}"+ Command="{Binding StartServerCommand}" />+ <Button Content="{DynamicResource engines.ollama.refresh}" Command="{Binding RefreshStatusCommand}" />+ </StackPanel>+ <StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">+ <Ellipse Width="10" Height="10"+ Fill="{Binding IsServerRunning, Converter={x:Static ObjectConverters.IsNull}}"+ Classes.running="{Binding IsServerRunning}" Classes.stopped="{Binding !IsServerRunning}">+ <Ellipse.Styles>+ <Style Selector="Ellipse.running">+ <Setter Property="Fill" Value="#22C55E" />+ </Style>+ <Style Selector="Ellipse.stopped">+ <Setter Property="Fill" Value="#EF4444" />+ </Style>+ </Ellipse.Styles>+ </Ellipse>+ <TextBlock FontWeight="SemiBold" Text="{Binding ServerStatusText}" VerticalAlignment="Center" />+ </StackPanel>+ </DockPanel>+ </Border>+ </StackPanel>++ <!-- Main Content -->+ <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">+ <StackPanel Spacing="14">+ <!-- Pull / Install Model Section -->+ <Border Classes="card" Padding="14">+ <StackPanel Spacing="8">+ <TextBlock Classes="h3" Text="{DynamicResource engines.ollama.pull_title}" />+ <Grid ColumnDefinitions="*,10,Auto">+ <TextBox Grid.Column="0" Text="{Binding NewModelName}"+ PlaceholderText="{DynamicResource engines.ollama.pull_placeholder}"+ IsEnabled="{Binding !IsPulling}" />+ <Button Grid.Column="2" Classes="accent" Content="{DynamicResource engines.ollama.pull_button}"+ Command="{Binding PullModelCommand}"+ IsEnabled="{Binding CanPull}" />+ </Grid>++ <!-- Warning for Cloud Models -->+ <Border Background="#33F97316" BorderBrush="#F97316" BorderThickness="1" CornerRadius="4" Padding="10,6"+ IsVisible="{Binding IsCloudWarningVisible}">+ <TextBlock Foreground="#EA580C" TextWrapping="Wrap"+ Text="{DynamicResource engines.ollama.cloud_warning}" />+ </Border>++ <!-- Download Progress -->+ <StackPanel Spacing="4" IsVisible="{Binding IsPulling}">+ <ProgressBar Maximum="100" Value="{Binding PullProgress}" />+ <TextBlock Classes="caption" Text="{Binding PullStatusText}" />+ </StackPanel>+ </StackPanel>+ </Border>++ <!-- Installed Models Section -->+ <Border Classes="card" Padding="14">+ <StackPanel Spacing="10">+ <TextBlock Classes="h3" Text="{DynamicResource engines.ollama.installed_models}" />++ <!-- Empty Notice -->+ <TextBlock Classes="caption" Text="{DynamicResource engines.ollama.no_models}"+ IsVisible="{Binding !Models.Count}" />++ <ItemsControl ItemsSource="{Binding Models}">+ <ItemsControl.ItemsPanel>+ <ItemsPanelTemplate>+ <StackPanel Spacing="8" />+ </ItemsPanelTemplate>+ </ItemsControl.ItemsPanel>+ <ItemsControl.ItemTemplate>+ <DataTemplate x:DataType="vm:OllamaModelItem">+ <Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="6" Padding="12,10">+ <DockPanel LastChildFill="True">+ <!-- Right Action Button -->+ <Button DockPanel.Dock="Right" Content="{Binding ActionText}"+ IsEnabled="{Binding IsActionEnabled}"+ Command="{Binding $parent[Window].((vm:OllamaModelManagerViewModel)DataContext).UseModelCommand}"+ CommandParameter="{Binding}"+ Classes.using="{Binding IsUsing}"+ MinWidth="120" HorizontalContentAlignment="Center">+ <Button.Styles>+ <Style Selector="Button.using">+ <Setter Property="Foreground" Value="#16A34A" />+ <Setter Property="FontWeight" Value="SemiBold" />+ </Style>+ </Button.Styles>+ </Button>++ <!-- Left Details -->+ <StackPanel Spacing="4" VerticalAlignment="Center">+ <StackPanel Orientation="Horizontal" Spacing="8">+ <TextBlock FontWeight="SemiBold" Text="{Binding Name}" />+ <!-- Badge -->+ <Border CornerRadius="4" Padding="6,2"+ Background="{Binding IsCloud, Converter={x:Static ObjectConverters.IsNull}}"+ Classes.cloud="{Binding IsCloud}" Classes.offline="{Binding !IsCloud}">+ <Border.Styles>+ <Style Selector="Border.cloud">+ <Setter Property="Background" Value="#33EA580C" />+ </Style>+ <Style Selector="Border.offline">+ <Setter Property="Background" Value="#2216A34A" />+ </Style>+ </Border.Styles>+ <TextBlock Classes="caption"+ Foreground="{Binding IsCloud, Converter={x:Static ObjectConverters.IsNull}}"+ Classes.cloudText="{Binding IsCloud}" Classes.offlineText="{Binding !IsCloud}">+ <TextBlock.Styles>+ <Style Selector="TextBlock.cloudText">+ <Setter Property="Foreground" Value="#EA580C" />+ <Setter Property="Text" Value="{DynamicResource engines.ollama.cloud_blocked}" />+ </Style>+ <Style Selector="TextBlock.offlineText">+ <Setter Property="Foreground" Value="#16A34A" />+ <Setter Property="Text" Value="{DynamicResource engines.ollama.offline_badge}" />+ </Style>+ </TextBlock.Styles>+ </TextBlock>+ </Border>+ </StackPanel>+ <TextBlock Classes="caption" Text="{Binding SizeFormatted}" IsVisible="{Binding SizeFormatted, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />+ </StackPanel>+ </DockPanel>+ </Border>+ </DataTemplate>+ </ItemsControl.ItemTemplate>+ </ItemsControl>+ </StackPanel>+ </Border>+ </StackPanel>+ </ScrollViewer>++ <!-- Footer -->+ <Button Grid.Row="2" Classes="accent" HorizontalAlignment="Right" Margin="0,14,0,0" MinWidth="88"+ HorizontalContentAlignment="Center" Content="{DynamicResource common.close}"+ Click="OnClose" IsDefault="True" IsCancel="True" />+ </Grid>+</Window>diff --git a/src/Filee.App/Views/OllamaModelManagerWindow.axaml.cs b/src/Filee.App/Views/OllamaModelManagerWindow.axaml.csnew file mode 100644index 00000000..7dbf3317--- /dev/null+++ b/src/Filee.App/Views/OllamaModelManagerWindow.axaml.cs@@ -0,0 +1,16 @@+using Avalonia.Controls;+using Avalonia.Interactivity;+using Filee.App.ViewModels;++namespace Filee.App.Views;++public partial class OllamaModelManagerWindow : Window+{+ public OllamaModelManagerWindow()+ {+ InitializeComponent();+ DataContext = new OllamaModelManagerViewModel();+ }++ private void OnClose(object? sender, RoutedEventArgs e) => Close();+}diff --git a/src/Filee.App/Views/Pages/EnginesPage.axaml b/src/Filee.App/Views/Pages/EnginesPage.axamlindex e9b72449..4b2fd1e3 100644--- a/src/Filee.App/Views/Pages/EnginesPage.axaml+++ b/src/Filee.App/Views/Pages/EnginesPage.axaml@@ -52,7 +52,13 @@<Border Classes="card" Padding="16,12"><DockPanel><StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Spacing="6" VerticalAlignment="Center" Margin="12,0,0,0">- <Button IsVisible="{Binding HasSettings}" Click="OnPackageSettings" ToolTip.Tip="{DynamicResource engines.lo_title}">+ <Button Classes="accent" IsVisible="{Binding IsTranslator}" Click="OnPackageSettings" ToolTip.Tip="{Binding SettingsTooltip}">+ <StackPanel Orientation="Horizontal" Spacing="6">+ <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Settings}" />+ <TextBlock Text="{DynamicResource engines.ollama.manage}" />+ </StackPanel>+ </Button>+ <Button IsVisible="{Binding IsLibreOffice}" Click="OnPackageSettings" ToolTip.Tip="{DynamicResource engines.lo_title}"><StackPanel Orientation="Horizontal" Spacing="6"><PathIcon Width="13" Height="13" Data="{StaticResource Icon.Settings}" /><TextBlock Text="{DynamicResource engines.settings}" />diff --git a/src/Filee.App/Views/Pages/EnginesPage.axaml.cs b/src/Filee.App/Views/Pages/EnginesPage.axaml.csindex 652d1eed..7ac52522 100644--- a/src/Filee.App/Views/Pages/EnginesPage.axaml.cs+++ b/src/Filee.App/Views/Pages/EnginesPage.axaml.cs@@ -122,10 +122,19 @@ public partial class EnginesPage : UserControlVm?.SavePriority();}- /// <summary>The LibreOffice switches, in their own window.</summary>+ /// <summary>The LibreOffice switches or Ollama model manager, in their own window.</summary>private async void OnPackageSettings(object? sender, RoutedEventArgs e){- if (DataContext is EnginesPageViewModel vm && TopLevel.GetTopLevel(this) is Window window)+ if (TopLevel.GetTopLevel(this) is not Window window)+ return;++ if (sender is Button { DataContext: EnginePackageState { Package.Id: "translator" } })+ {+ await new OllamaModelManagerWindow().ShowDialog(window);+ return;+ }++ if (DataContext is EnginesPageViewModel vm)await new LibreOfficeOptionsWindow { DataContext = vm }.ShowDialog(window);}diff --git a/src/Filee.App/Views/PresetEditorView.axaml b/src/Filee.App/Views/PresetEditorView.axamlindex b462ac2b..370e3b57 100644--- a/src/Filee.App/Views/PresetEditorView.axaml+++ b/src/Filee.App/Views/PresetEditorView.axaml@@ -240,6 +240,34 @@</StackPanel></Border>+ <!-- Translation options -->++ <Border x:Name="TranslateCard" Classes="card" IsVisible="{Binding ShowTranslate}" Padding="14">++ <StackPanel Spacing="10">++ <TextBlock Classes="h2" Text="{DynamicResource presets.group.translate}" />++ <TextBlock Classes="caption" TextWrapping="Wrap" Text="{DynamicResource presets.translate_hint}" />++ <Grid ColumnDefinitions="*,12,*">++ <StackPanel>++ <TextBlock Classes="label" Text="{DynamicResource presets.target_language}" />++ <ComboBox ItemsSource="{Binding TranslationLanguageChoices}" SelectedItem="{Binding TargetLanguage}" HorizontalAlignment="Stretch" AutomationProperties.Name="{DynamicResource presets.target_language}" />++ </StackPanel>++ </Grid>++ </StackPanel>++ </Border>+++<!-- Video & audio options --><Border x:Name="MediaCard" Classes="card" IsVisible="{Binding ShowMedia}" Padding="14"><StackPanel Spacing="10">diff --git a/src/Filee.Core/Conversion/IConverter.cs b/src/Filee.Core/Conversion/IConverter.csindex 48fa9dcf..7594e627 100644--- a/src/Filee.Core/Conversion/IConverter.cs+++ b/src/Filee.Core/Conversion/IConverter.cs@@ -61,7 +61,7 @@ namespace Filee.Core.Conversion;public readonly record struct ConversionEdge(string From, string To, int Cost = 10, bool ImageSourcesOnly = false, bool NotForImageSources = false,bool DirectOnly = false, bool FrameSequence = false, bool Unshaped = false, bool MotionPhoto = false, bool LivePhoto = false,- bool Ocr = false, bool Caption = false);+ bool Ocr = false, bool Caption = false, bool Translate = false);/// <summary>/// A conversion an engine refuses with a reason the user can act on, shown in their language (the file's@@ -145,7 +145,8 @@ public sealed record ConversionStep(bool LivePhoto = false,Action<IReadOnlyList<string>>? MissingFonts = null,string? OriginalSourcePath = null,- bool Caption = false);+ bool Caption = false,+ bool Translate = false);/// <summary>/// A conversion engine (ImageMagick, LibreOffice, rhwp, ...).diff --git a/src/Filee.Core/Conversion/JobQueue.cs b/src/Filee.Core/Conversion/JobQueue.csindex 2c050611..7c1c0b8e 100644--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@ -872,7 +872,7 @@ public sealed partial class JobQueue : IAsyncDisposablefile.MissingFonts = file.MissingFonts.Concat(fonts).Distinct(StringComparer.OrdinalIgnoreCase).ToList();Notify(job);- }, file.SourcePath, Caption: step.Caption);+ }, file.SourcePath, Caption: step.Caption, Translate: step.Translate);outputs.AddRange(await step.Converter.ConvertAsync(stepInfo, progress, ct));}finallydiff --git a/src/Filee.Core/Conversion/RoutePlanner.cs b/src/Filee.Core/Conversion/RoutePlanner.csindex d6f4cd31..796058f0 100644--- a/src/Filee.Core/Conversion/RoutePlanner.cs+++ b/src/Filee.Core/Conversion/RoutePlanner.cs@@ -15,7 +15,7 @@ namespace Filee.Core.Conversion;/// <param name="LivePhoto">The hop makes a Live / Motion Photo of a video (<see cref="ConversionEdge.LivePhoto"/>).</param>/// <param name="Caption">The hop transcribes speech to SRT subtitles using Whisper (<see cref="ConversionEdge.Caption"/>).</param>public sealed record RouteStep(IConverter Converter, string From, string To, bool FrameSequence = false, bool Unshaped = false,- bool MotionPhoto = false, bool LivePhoto = false, bool Caption = false);+ bool MotionPhoto = false, bool LivePhoto = false, bool Caption = false, bool Translate = false);/// <summary>A planned conversion from one format to another.</summary>public sealed record Route(IReadOnlyList<RouteStep> Steps, int Cost)@@ -82,7 +82,7 @@ public sealed class RoutePlanner/// </param>/// <param name="caption">Transcribe speech to SRT subtitles using Whisper (<see cref="Presets.Preset.CaptionsVideo"/>).</param>public Route? Plan(string from, string to, bool frames = false, bool shaping = false, bool motionPhoto = false, bool livePhoto = false,- bool ocr = false, bool caption = false)+ bool ocr = false, bool caption = false, bool translate = false){from = from.ToLowerInvariant();to = to.ToLowerInvariant();@@ -90,19 +90,20 @@ public sealed class RoutePlannerif (ocr)return PlanWithOcr(from, to, shaping);- if (frames || motionPhoto || livePhoto || caption)+ if (frames || motionPhoto || livePhoto || caption || translate){- // One of them: frames, then the video of a photo, then a photo of a video, then caption.+ // One of them: frames, then the video of a photo, then a photo of a video, then caption, then translate.motionPhoto &= !frames;livePhoto &= !frames && !motionPhoto;caption &= !frames && !motionPhoto && !livePhoto;+ translate &= !frames && !motionPhoto && !livePhoto && !caption;var special = EdgesFrom(from)- .Where(e => e.Edge.To == to && (frames ? e.Edge.FrameSequence : motionPhoto ? e.Edge.MotionPhoto : livePhoto ? e.Edge.LivePhoto : e.Edge.Caption))+ .Where(e => e.Edge.To == to && (frames ? e.Edge.FrameSequence : motionPhoto ? e.Edge.MotionPhoto : livePhoto ? e.Edge.LivePhoto : caption ? e.Edge.Caption : e.Edge.Translate)).OrderBy(e => e.Cost).FirstOrDefault();return special.Converter is null? null- : new Route([new RouteStep(special.Converter, from, to, FrameSequence: frames, MotionPhoto: motionPhoto, LivePhoto: livePhoto, Caption: caption)],+ : new Route([new RouteStep(special.Converter, from, to, FrameSequence: frames, MotionPhoto: motionPhoto, LivePhoto: livePhoto, Caption: caption, Translate: translate)],special.Cost);}@@ -110,7 +111,7 @@ public sealed class RoutePlannerif (from == to){var best = EdgesFrom(from)- .Where(e => e.Edge.To == to && !e.Edge.FrameSequence && !e.Edge.MotionPhoto && !e.Edge.LivePhoto && !e.Edge.Ocr && !e.Edge.Caption)+ .Where(e => e.Edge.To == to && !e.Edge.FrameSequence && !e.Edge.MotionPhoto && !e.Edge.LivePhoto && !e.Edge.Ocr && !e.Edge.Caption && !e.Edge.Translate).OrderBy(e => e.Cost).FirstOrDefault();return best.Converter is null@@ -139,7 +140,7 @@ public sealed class RoutePlannerforeach (var (converter, edge, edgeCost) in EdgesFrom(node)){- if (edge.To == edge.From || edge.FrameSequence || edge.MotionPhoto || edge.LivePhoto || edge.Ocr || edge.Caption+ if (edge.To == edge.From || edge.FrameSequence || edge.MotionPhoto || edge.LivePhoto || edge.Ocr || edge.Translate || edge.Caption|| (edge.ImageSourcesOnly && !imageSource) || (edge.NotForImageSources && imageSource)|| (edge.Unshaped && shaping)|| (edge.DirectOnly && (node != from || edge.To != to)))@@ -171,7 +172,7 @@ public sealed class RoutePlanner/// <param name="livePhoto">A Live / Motion Photo of a video (see <see cref="Plan"/>).</param>/// <param name="ocr">Recognize the text first (see <see cref="Plan"/>).</param>/// <param name="caption">Transcribe speech to SRT subtitles using Whisper (see <see cref="Plan"/>).</param>- public bool CanConvert(string from, string to, bool frames = false, bool motionPhoto = false, bool livePhoto = false, bool ocr = false, bool caption = false) =>+ public bool CanConvert(string from, string to, bool frames = false, bool motionPhoto = false, bool livePhoto = false, bool ocr = false, bool caption = false, bool translate = false) =>Plan(from, to, frames, motionPhoto: motionPhoto, livePhoto: livePhoto, ocr: ocr, caption: caption) is not null;private Route? PlanWithOcr(string from, string to, bool shaping)diff --git a/src/Filee.Core/Presets/BuiltInData.cs b/src/Filee.Core/Presets/BuiltInData.csindex d92aa7d8..06bcda54 100644--- a/src/Filee.Core/Presets/BuiltInData.cs+++ b/src/Filee.Core/Presets/BuiltInData.cs@@ -44,6 +44,22 @@ public static class BuiltInDataImage = { RemoveBackground = true }, Output = { FileNamePattern = "{name}_transparent" },},.. TrimPresets(),++ new()++ {++ Id = "translate",++ NameKey = "preset.translate",++ TargetFormat = SameAsSource,++ Translate = new TranslateOptions { Enabled = true, TargetLanguage = "en" },++ Output = { FileNamePattern = "{name}_{lang}" },++ },new(){Id = "tool-crop", NameKey = "preset.crop", TargetFormat = SameAsSource,@@ -588,14 +604,14 @@ public static class BuiltInDataId = "pdf", NameKey = "profile.pdf",Extensions = ["pdf"],PresetIds = [.. PdfDonut],- BackPresetIds = ["pdf-edit", "compress-pdf", "to-webp", "to-tiff", "to-html", "to-odt", "to-rtf", "to-azw3", "to-cbz", "remove-metadata", "zip-all"],+ BackPresetIds = ["pdf-edit", "compress-pdf", "to-webp", "to-tiff", "to-html", "to-odt", "to-rtf", "to-azw3", "to-cbz", "translate", "remove-metadata", "zip-all"],},new(){Id = "office", NameKey = "profile.office",Extensions = ExtensionsOf(FormatCategory.Document),PresetIds = ["to-pdf", "to-hwpx", "to-hwp", "to-docx", "to-odt", "to-txt", "to-html", "to-epub", "to-png", "merge-pdf"],- BackPresetIds = ["to-md", "to-rtf", "to-jpg", "pdf-long-image", "to-azw3", "to-kepub", "zip-all"],+ BackPresetIds = ["translate", "to-md", "to-rtf", "to-jpg", "pdf-long-image", "to-azw3", "to-kepub", "zip-all"],},SpreadsheetProfile(),PresentationProfile(),@@ -604,7 +620,7 @@ public static class BuiltInDataId = "hwp", NameKey = "profile.hwp",Extensions = ["hwp", "hwpx"],PresetIds = ["to-pdf", "to-docx", "to-hwpx", "to-hwp", "to-png", "to-jpg", "to-txt", "to-md", "to-epub", "merge-pdf"],- BackPresetIds = ["to-html", "to-odt", "to-rtf", "pdf-long-image", "to-azw3", "zip-all"],+ BackPresetIds = ["translate", "to-html", "to-odt", "to-rtf", "pdf-long-image", "to-azw3", "zip-all"],},TextProfile(),.. WithSubtitleProfile(CatalogProfiles()),@@ -657,7 +673,7 @@ public static class BuiltInDataNameKey = "profile.text",Extensions = ExtensionsOf(FormatCategory.Text),PresetIds = ["to-pdf", "to-hwpx", "to-hwp", "to-docx", "to-html", "to-txt", "to-epub"],- BackPresetIds = ["to-md", "to-odt", "to-rtf", "to-kepub", "merge-pdf", "zip-all"],+ BackPresetIds = ["translate", "to-md", "to-odt", "to-rtf", "to-kepub", "merge-pdf", "zip-all"],};/// <summary>Donuts of the categories added in settings schema 6, in the order they follow "text".</summary>@@ -668,7 +684,7 @@ public static class BuiltInDataId = "ebooks", NameKey = "profile.ebooks",Extensions = ExtensionsOf(FormatCategory.Ebook),PresetIds = ["to-pdf", "to-epub", "to-docx", "to-txt", "to-azw3", "to-mobi", "to-kepub", "to-hwpx", "to-hwp", "to-html"],- BackPresetIds = ["to-fb2", "to-md", "to-rtf", "to-odt", "merge-pdf", "zip-all"],+ BackPresetIds = ["translate", "to-fb2", "to-md", "to-rtf", "to-odt", "merge-pdf", "zip-all"],},new(){diff --git a/src/Filee.Core/Presets/Preset.cs b/src/Filee.Core/Presets/Preset.csindex 6183cc4e..4c13b701 100644--- a/src/Filee.Core/Presets/Preset.cs+++ b/src/Filee.Core/Presets/Preset.cs@@ -118,6 +118,12 @@ public sealed class Preset/// <summary>Options used when a DWG or DXF is written or drawn.</summary>public CadOptions Cad { get; set; } = new();+++ /// <summary>Options used for offline AI translation.</summary>++ public TranslateOptions Translate { get; set; } = new();+/// <summary>Where and how output files are written.</summary>public OutputRule Output { get; set; } = new();@@ -157,6 +163,21 @@ public sealed class Preset/// (<see cref="MediaOptions.SaveEveryFrame"/>): the file is a video and the target one of/// <see cref="MediaOptions.FrameTargets"/>. Other files, and other targets, convert as usual./// </summary>+ public bool TranslatesDocument(string sourceFormat)+ {+ if (!Translate.Enabled)+ return false;+ var fmt = Formats.FormatRegistry.FindById(sourceFormat);+ if (fmt is null)+ return false;+ return fmt.Category is Formats.FormatCategory.Document+ or Formats.FormatCategory.Ebook+ or Formats.FormatCategory.Text+ or Formats.FormatCategory.Data+ or Formats.FormatCategory.Subtitle+ || sourceFormat == "pdf";+ }+public bool SavesFramesOf(string sourceFormat) =>Media.SaveEveryFrame&& !MakesLivePhotoOf(sourceFormat)@@ -306,6 +327,8 @@ public sealed class PresetArchive = Archive.Clone(),Trace = Trace.Clone(),Cad = Cad.Clone(),++ Translate = Translate.Clone(),Output = Output.Clone(),Kind = Kind,Tool = Tool,@@ -1279,3 +1302,25 @@ public sealed class CadOptionspublic CadOptions Clone() => (CadOptions)MemberwiseClone();}+++/// <summary>Options for offline AI document translation.</summary>++public sealed class TranslateOptions++{++ public bool Enabled { get; set; } = true;++ public string TargetLanguage { get; set; } = "en";++ public string SourceLanguage { get; set; } = "auto";++ public string? Model { get; set; }++++ public TranslateOptions Clone() => (TranslateOptions)MemberwiseClone();++}+diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex f200e3fb..40ba012f 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -229,7 +229,10 @@ public sealed class AppSettings/// With LibreOffice installed, presentations (PPTX, PPT, ODP) → PDF go through it instead of the built-in route/// (HWPX writer and rhwp): slide backgrounds and shape positions come out as in PowerPoint./// </summary>- public bool LibreOfficeForSlides { get; set; } = true;+ public bool LibreOfficeForSlides { get; set; } = true;++ /// <summary>Active local model for offline translation (e.g. "llama3.2", "qwen2.5").</summary>+ public string? PreferredOllamaModel { get; set; }/// <summary>/// With LibreOffice and H2Orestart installed, HWP / HWPX → PDF go through it instead of rhwp: a way around adiff --git a/src/Filee.Core/Settings/FileeJsonContext.cs b/src/Filee.Core/Settings/FileeJsonContext.csindex 7bcc866c..5d1f1488 100644--- a/src/Filee.Core/Settings/FileeJsonContext.cs+++ b/src/Filee.Core/Settings/FileeJsonContext.cs@@ -16,7 +16,8 @@ namespace Filee.Core.Settings;AllowTrailingCommas = true)][JsonSerializable(typeof(AppSettings))][JsonSerializable(typeof(ThemeStyle))]-[JsonSerializable(typeof(List<Preset>))]+[JsonSerializable(typeof(List<Preset>))]+[JsonSerializable(typeof(TranslateOptions))][JsonSerializable(typeof(List<ToolbarProfile>))][JsonSerializable(typeof(PresetBundle))][JsonSerializable(typeof(List<HistoryEntry>))]diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex 6f13384c..70320bcd 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -281,6 +281,11 @@ public sealed class UserDataStore/// <summary>Removes dangling preset references and guarantees at least one mixed-selection profile.</summary>private void EnsureConsistency(){+ if (Presets.All(p => p.Id != "translate"))+ {+ if (BuiltInData.CreatePresets().FirstOrDefault(p => p.Id == "translate") is { } translatePreset)+ Presets.Add(translatePreset);+ }var ids = Presets.Select(p => p.Id).ToHashSet();foreach (var profile in Profiles){diff --git a/src/Filee.Engines/EngineRegistry.cs b/src/Filee.Engines/EngineRegistry.csindex b45c2983..73578c7b 100644--- a/src/Filee.Engines/EngineRegistry.cs+++ b/src/Filee.Engines/EngineRegistry.cs@@ -72,7 +72,8 @@ public static class EngineRegistrynew VisionConverter(), // before Tesseract: a Mac's OCR step (Tesseract reads the languages Vision doesn't)new TesseractConverter(),new CalibreConverter(),- new LibreOfficeConverter(env, loggers?.CreateLogger<LibreOfficeConverter>()),+ new LibreOfficeConverter(env, loggers?.CreateLogger<LibreOfficeConverter>()),+ new Translation.TranslatorConverter(loggers?.CreateLogger<Translation.TranslatorConverter>()),];/// <summary>Finds the PDF merger among the converters.</summary>diff --git a/src/Filee.Engines/Infrastructure/EngineDownloads.cs b/src/Filee.Engines/Infrastructure/EngineDownloads.csindex d4a90413..55b6358c 100644--- a/src/Filee.Engines/Infrastructure/EngineDownloads.cs+++ b/src/Filee.Engines/Infrastructure/EngineDownloads.cs@@ -55,6 +55,7 @@ public static class EngineDownloadsnew("calibre", ["calibre"], 663_000_000, ["calibre"]),new("tesseract", ["tesseract"], 168_000_000, ["tesseract"]),.. (OperatingSystem.IsWindows() ? [new EnginePackage("whisper", ["whisper", "whisper-model"], 156_880_105, ["whisper"])] : Array.Empty<EnginePackage>()),+ new("translator", ["translator"], 0, ["translator"]),];/// <summary>Total download size of a package in bytes.</summary>@@ -83,6 +84,10 @@ public static class EngineDownloads"tesseract" => "Install Tesseract using your distribution's package manager (Ubuntu/Debian: sudo apt install tesseract-ocr), then check again.",_ => $"No Filee download is available for {RuntimeIdentifier}. Install {package.Id} using your distribution's package manager and select its program folder.",};+ if (package.Id == "translator")++ return "Install local Ollama (https://ollama.com) with 'ollama run llama3.2' or place a local model in the engines folder. Everything runs 100% offline on your computer.";+return $"No Filee download is available for {RuntimeIdentifier}. Select a compatible installed copy.";}diff --git a/src/Filee.Engines/Infrastructure/EngineEnvironment.cs b/src/Filee.Engines/Infrastructure/EngineEnvironment.csindex baf5eaa2..0c176fc8 100644--- a/src/Filee.Engines/Infrastructure/EngineEnvironment.cs+++ b/src/Filee.Engines/Infrastructure/EngineEnvironment.cs@@ -88,7 +88,8 @@ public sealed class EngineEnvironment(string dataDirectory)["rhwp"] = [windows ? "rhwp.exe" : "rhwp"],["7zip"] = [windows ? "7z.exe" : "7zz"],["tesseract"] = [windows ? "tesseract.exe" : "tesseract"],- ["whisper"] = [windows ? "whisper-cli.exe" : "whisper-cli"],+ ["whisper"] = [windows ? "whisper-cli.exe" : "whisper-cli"],+ ["translator"] = [windows ? "translator.exe" : "translator"],};public static string ProgramName(string name) => OperatingSystem.IsWindows() ? namediff --git a/src/Filee.Engines/Translation/DocumentTranslator.cs b/src/Filee.Engines/Translation/DocumentTranslator.csnew file mode 100644index 00000000..6998be7e--- /dev/null+++ b/src/Filee.Engines/Translation/DocumentTranslator.cs@@ -0,0 +1,182 @@+using System.Text;+using System.Text.RegularExpressions;+using Filee.Engines.Ebooks;+using Filee.Engines.Hwp.Hwpx;++namespace Filee.Engines.Translation;++/// <summary>+/// Traverses and translates the in-memory HDocument AST while preserving all structure, tags, styles, images, and tables.+/// </summary>+internal static class DocumentTranslator+{+ private static readonly Regex TagRegex = new(@"<s(\d+)>(.*?)<\/s\1>", RegexOptions.Singleline | RegexOptions.Compiled);++ internal static async Task TranslateBookAsync(Book book, string toLang, string fromLang, ITranslationService service, IProgress<double>? progress, CancellationToken cancellationToken)+ {+ if (!string.IsNullOrWhiteSpace(book.Metadata.Title))+ {+ book.Metadata.Title = await service.TranslateTextAsync(book.Metadata.Title, toLang, fromLang, cancellationToken);+ }+ if (!string.IsNullOrWhiteSpace(book.Metadata.Description))+ {+ book.Metadata.Description = await service.TranslateTextAsync(book.Metadata.Description, toLang, fromLang, cancellationToken);+ }+ book.Metadata.Language = TranslationService.NormalizeLanguage(toLang);++ await TranslateDocumentAsync(book.Document, toLang, fromLang, service, progress, cancellationToken);+ }++ internal static async Task TranslateDocumentAsync(HDocument document, string toLang, string fromLang, ITranslationService service, IProgress<double>? progress, CancellationToken cancellationToken)+ {+ if (!string.IsNullOrWhiteSpace(document.Title))+ {+ document.Title = await service.TranslateTextAsync(document.Title, toLang, fromLang, cancellationToken);+ }++ var paragraphs = CollectParagraphs(document).ToList();+ if (paragraphs.Count == 0)+ {+ progress?.Report(1.0);+ return;+ }++ // Filter paragraphs that contain actual translatable text+ var workItems = new List<(HParagraph Paragraph, string EncodedText, List<(int Index, HText TextInline)> Map)>();+ foreach (var p in paragraphs)+ {+ var textInlines = new List<(int Index, HText TextInline)>();+ for (var i = 0; i < p.Inlines.Count; i++)+ {+ if (p.Inlines[i] is HText textNode && !string.IsNullOrWhiteSpace(textNode.Text))+ {+ textInlines.Add((i, textNode));+ }+ }++ if (textInlines.Count == 0)+ continue;++ if (textInlines.Count == 1)+ {+ // Single inline: no tags needed+ workItems.Add((p, textInlines[0].TextInline.Text, textInlines));+ }+ else+ {+ // Multiple inlines: wrap with <s{i}> tags so formatting boundaries are maintained+ var sb = new StringBuilder();+ for (var i = 0; i < p.Inlines.Count; i++)+ {+ if (p.Inlines[i] is HText textNode)+ {+ sb.Append($"<s{i}>{textNode.Text}</s{i}>");+ }+ }+ workItems.Add((p, sb.ToString(), textInlines));+ }+ }++ if (workItems.Count == 0)+ {+ progress?.Report(1.0);+ return;+ }++ // Translate in chunks of up to 25 paragraphs+ const int chunkSize = 25;+ var total = workItems.Count;+ var done = 0;++ for (var i = 0; i < workItems.Count; i += chunkSize)+ {+ cancellationToken.ThrowIfCancellationRequested();++ var chunk = workItems.Skip(i).Take(chunkSize).ToList();+ var texts = chunk.Select(c => c.EncodedText).ToList();++ var translatedBatch = await service.TranslateBatchAsync(texts, toLang, fromLang, cancellationToken);++ for (var j = 0; j < chunk.Count; j++)+ {+ var item = chunk[j];+ var translated = translatedBatch[j];++ if (item.Map.Count == 1)+ {+ var (idx, node) = item.Map[0];+ item.Paragraph.Inlines[idx] = new HText(translated, node.Format);+ }+ else+ {+ // Match back <s{i}> tags+ var matches = TagRegex.Matches(translated);+ var matchedIndices = new HashSet<int>();++ foreach (Match match in matches)+ {+ if (int.TryParse(match.Groups[1].Value, out var inlineIdx)+ && inlineIdx >= 0 && inlineIdx < item.Paragraph.Inlines.Count+ && item.Paragraph.Inlines[inlineIdx] is HText originalNode)+ {+ item.Paragraph.Inlines[inlineIdx] = new HText(match.Groups[2].Value, originalNode.Format);+ matchedIndices.Add(inlineIdx);+ }+ }++ // Fallback if tags were stripped or altered by the model+ if (matchedIndices.Count == 0 && item.Map.Count > 0)+ {+ var (firstIdx, firstNode) = item.Map[0];+ // Put full text in first inline, empty subsequent inlines+ item.Paragraph.Inlines[firstIdx] = new HText(StripTags(translated), firstNode.Format);+ for (var k = 1; k < item.Map.Count; k++)+ {+ var (subIdx, subNode) = item.Map[k];+ item.Paragraph.Inlines[subIdx] = new HText("", subNode.Format);+ }+ }+ }+ }++ done += chunk.Count;+ progress?.Report((double)done / total);+ }++ progress?.Report(1.0);+ }++ private static string StripTags(string text) =>+ Regex.Replace(text, @"<\/?[a-zA-Z0-9]+.*?>", "");++ private static IEnumerable<HParagraph> CollectParagraphs(HDocument doc)+ {+ foreach (var sec in doc.Sections)+ {+ foreach (var p in CollectBlockParagraphs(sec.Blocks))+ yield return p;+ }+ }++ private static IEnumerable<HParagraph> CollectBlockParagraphs(IEnumerable<HBlock> blocks)+ {+ foreach (var block in blocks)+ {+ switch (block)+ {+ case HParagraph p:+ yield return p;+ break;+ case HTable table:+ foreach (var p in CollectBlockParagraphs(table.Caption))+ yield return p;+ foreach (var cell in table.Rows.SelectMany(r => r.Cells))+ {+ foreach (var p in CollectBlockParagraphs(cell.Blocks))+ yield return p;+ }+ break;+ }+ }+ }+}diff --git a/src/Filee.Engines/Translation/ITranslationService.cs b/src/Filee.Engines/Translation/ITranslationService.csnew file mode 100644index 00000000..6d8c3169--- /dev/null+++ b/src/Filee.Engines/Translation/ITranslationService.cs@@ -0,0 +1,14 @@+namespace Filee.Engines.Translation;++public interface ITranslationService+{+ /// <summary>+ /// Translates a single text segment from <paramref name="fromLang"/> (or auto-detect) to <paramref name="toLang"/>.+ /// </summary>+ Task<string> TranslateTextAsync(string text, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default);++ /// <summary>+ /// Translates a batch of text segments, preserving ordering and any embedded inline formatting tags.+ /// </summary>+ Task<IReadOnlyList<string>> TranslateBatchAsync(IReadOnlyList<string> texts, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default);+}diff --git a/src/Filee.Engines/Translation/TranslationService.cs b/src/Filee.Engines/Translation/TranslationService.csnew file mode 100644index 00000000..9c20e55b--- /dev/null+++ b/src/Filee.Engines/Translation/TranslationService.cs@@ -0,0 +1,322 @@+using System.Diagnostics;+using System.Net.Http.Json;+using System.Text.Json;+using Filee.Core.Presets;+using Filee.Engines.Infrastructure;+using Microsoft.Extensions.Logging;++namespace Filee.Engines.Translation;++/// <summary>+/// Offline document and text translation service powered by local AI (Ollama or local offline models).+/// Strictly runs on the user's computer: no text is ever uploaded or sent to third-party web services.+/// </summary>+public sealed class TranslationService : ITranslationService+{+ private static readonly TimeSpan OllamaTimeout = TimeSpan.FromMinutes(2);+ private static readonly Uri LocalOllamaBase = new("http://127.0.0.1:11434");++ private readonly TranslateOptions _options;+ private readonly ILogger? _logger;+ private readonly HttpClient? _http;++ public TranslationService(TranslateOptions? options = null, HttpClient? httpClient = null, ILogger? logger = null)+ {+ _options = options ?? new TranslateOptions();+ _http = httpClient;+ _logger = logger;+ }++ public static string NormalizeLanguage(string? lang)+ {+ if (string.IsNullOrWhiteSpace(lang))+ return "en";+ var trimmed = lang.Trim();+ return LanguageMap.TryGetValue(trimmed, out var code) ? code : trimmed.ToLowerInvariant();+ }++ public static string LanguageDisplayName(string code)+ {+ var norm = NormalizeLanguage(code);+ return CodeToNameMap.TryGetValue(norm, out var name) ? name : code;+ }++ public static string? ActiveOllamaModel { get; set; }++ /// <summary>+ /// Checks whether an Ollama model forwards prompts to the cloud (e.g. models ending in '-cloud' or containing 'cloud').+ /// Cloud models are strictly prohibited to ensure document text never leaves the computer.+ /// </summary>+ public static bool IsCloudModel(string? modelName)+ {+ if (string.IsNullOrWhiteSpace(modelName))+ return false;+ var name = modelName.Trim();+ return name.EndsWith("-cloud", StringComparison.OrdinalIgnoreCase)+ || name.EndsWith(":cloud", StringComparison.OrdinalIgnoreCase)+ || name.Contains("-cloud:", StringComparison.OrdinalIgnoreCase)+ || name.Contains("/cloud", StringComparison.OrdinalIgnoreCase)+ || name.IndexOf("cloud", StringComparison.OrdinalIgnoreCase) >= 0;+ }++ public static async Task<bool> IsLocalOllamaAvailableAsync(CancellationToken cancellationToken = default)+ {+ try+ {+ using var client = new HttpClient { Timeout = TimeSpan.FromMilliseconds(500) };+ using var res = await client.GetAsync(new Uri(LocalOllamaBase, "/api/tags"), cancellationToken);+ return res.IsSuccessStatusCode;+ }+ catch+ {+ return false;+ }+ }++ public static async Task<string?> GetPreferredLocalOllamaModelAsync(CancellationToken cancellationToken = default)+ {+ try+ {+ using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(1) };+ using var res = await client.GetAsync(new Uri(LocalOllamaBase, "/api/tags"), cancellationToken);+ if (!res.IsSuccessStatusCode)+ return null;++ using var doc = await JsonDocument.ParseAsync(await res.Content.ReadAsStreamAsync(cancellationToken), cancellationToken: cancellationToken);+ if (doc.RootElement.TryGetProperty("models", out var models) && models.ValueKind == JsonValueKind.Array)+ {+ var names = models.EnumerateArray()+ .Select(m => m.TryGetProperty("name", out var n) ? n.GetString() : null)+ .Where(n => !string.IsNullOrEmpty(n) && !IsCloudModel(n))+ .Select(n => n!)+ .ToList();++ if (names.Count == 0)+ return null;++ if (!string.IsNullOrWhiteSpace(ActiveOllamaModel) && names.Contains(ActiveOllamaModel, StringComparer.OrdinalIgnoreCase))+ return ActiveOllamaModel;++ // Prefer specialized or standard instruction models+ string[] preferred = ["qwen2.5", "llama3.2", "llama3", "mistral", "gemma2", "phi3", "phi4"];+ foreach (var p in preferred)+ {+ var match = names.FirstOrDefault(n => n.StartsWith(p, StringComparison.OrdinalIgnoreCase));+ if (match is not null)+ return match;+ }+ return names[0];+ }+ }+ catch+ {+ // Ignore connection errors+ }+ return null;+ }++ public async Task<string> TranslateTextAsync(string text, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default)+ {+ if (string.IsNullOrWhiteSpace(text))+ return text;++ var targetLang = NormalizeLanguage(toLang);+ var sourceLang = string.IsNullOrWhiteSpace(fromLang) || fromLang.Equals("auto", StringComparison.OrdinalIgnoreCase) ? "auto" : NormalizeLanguage(fromLang);++ if (string.Equals(sourceLang, targetLang, StringComparison.OrdinalIgnoreCase))+ return text;++ if (!string.IsNullOrWhiteSpace(_options.Model) && IsCloudModel(_options.Model))+ throw new InvalidOperationException("Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer.");++ // 1. Try local Ollama (100% offline on http://127.0.0.1:11434)+ if (await IsLocalOllamaAvailableAsync(cancellationToken))+ {+ var model = (!string.IsNullOrWhiteSpace(_options.Model) ? _options.Model : await GetPreferredLocalOllamaModelAsync(cancellationToken)) ?? "llama3.2";+ if (IsCloudModel(model))+ throw new InvalidOperationException("Security Block: Cloud-forwarded models (-cloud) are blocked to ensure document text never leaves your computer.");+ return await TranslateWithLocalOllamaAsync(text, targetLang, sourceLang, model, cancellationToken);+ }++ // 2. Try local CLI engine if installed in Filee's engines folder+ if (LocateLocalEngine() is { } cli && File.Exists(cli))+ {+ return await TranslateWithLocalCliAsync(cli, text, targetLang, sourceLang, cancellationToken);+ }++ throw new InvalidOperationException(+ "Local offline translation requires Ollama running on your computer (http://localhost:11434) or the Translator engine in Settings → Engines. " ++ "Filee converts files on your own computer and never uploads them.");+ }++ public async Task<IReadOnlyList<string>> TranslateBatchAsync(IReadOnlyList<string> texts, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default)+ {+ if (texts.Count == 0)+ return [];++ var results = new string[texts.Count];+ var semaphore = new SemaphoreSlim(4, 4);+ var tasks = new List<Task>();++ for (var i = 0; i < texts.Count; i++)+ {+ var index = i;+ var text = texts[index];+ if (string.IsNullOrWhiteSpace(text))+ {+ results[index] = text;+ continue;+ }++ tasks.Add(Task.Run(async () =>+ {+ await semaphore.WaitAsync(cancellationToken);+ try+ {+ results[index] = await TranslateTextAsync(text, toLang, fromLang, cancellationToken);+ }+ finally+ {+ semaphore.Release();+ }+ }, cancellationToken));+ }++ await Task.WhenAll(tasks);+ return results;+ }++ private async Task<string> TranslateWithLocalOllamaAsync(string text, string targetLang, string sourceLang, string model, CancellationToken cancellationToken)+ {+ var targetName = LanguageDisplayName(targetLang);+ var prompt = $"You are a professional book and document translator. Translate the following text into {targetName}.\n" ++ "Rules:\n" ++ "- Preserve all formatting tags (such as <b>, <i>, <a>, <s0>, <s1>, etc.) exactly.\n" ++ "- Maintain the exact same paragraph and line structure.\n" ++ "- Output ONLY the translated text without commentary, intro or explanation.\n\n" ++ $"{text}";++ var requestBody = new+ {+ model,+ prompt,+ stream = false,+ options = new { temperature = 0.1 }+ };++ using var client = _http ?? new HttpClient { Timeout = OllamaTimeout };+ using var response = await client.PostAsJsonAsync(new Uri(LocalOllamaBase, "/api/generate"), requestBody, cancellationToken);+ response.EnsureSuccessStatusCode();++ using var json = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync(cancellationToken), cancellationToken: cancellationToken);+ if (json.RootElement.TryGetProperty("response", out var resp))+ return resp.GetString()?.Trim() ?? text;++ return text;+ }++ private static async Task<string> TranslateWithLocalCliAsync(string cliPath, string text, string targetLang, string sourceLang, CancellationToken cancellationToken)+ {+ var targetName = LanguageDisplayName(targetLang);+ var prompt = $"Translate into {targetName}:\n{text}";++ var psi = new ProcessStartInfo+ {+ FileName = cliPath,+ Arguments = $"-p \"{prompt.Replace("\"", "\\\"")}\" --temp 0.1",+ RedirectStandardOutput = true,+ RedirectStandardError = true,+ UseShellExecute = false,+ CreateNoWindow = true+ };++ using var process = Process.Start(psi) ?? throw new InvalidOperationException("Failed to launch local translator process.");+ using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);+ cts.CancelAfter(TimeSpan.FromMinutes(2));++ var output = await process.StandardOutput.ReadToEndAsync(cts.Token);+ await process.WaitForExitAsync(cts.Token);++ return !string.IsNullOrWhiteSpace(output) ? output.Trim() : text;+ }++ internal static string? LocateLocalEngine()+ {+ return EngineEnvironment.OwnProgram("translator", "translator.exe")+ ?? EngineEnvironment.BundledProgram("translator", "translator.exe")+ ?? EngineEnvironment.SystemProgram("translator", "translator.exe")+ ?? EngineEnvironment.SystemProgram("ollama", "ollama.exe");+ }++ private static readonly Dictionary<string, string> LanguageMap = new(StringComparer.OrdinalIgnoreCase)+ {+ ["en"] = "en",+ ["english"] = "en",+ ["es"] = "es",+ ["spanish"] = "es",+ ["español"] = "es",+ ["fr"] = "fr",+ ["french"] = "fr",+ ["français"] = "fr",+ ["de"] = "de",+ ["german"] = "de",+ ["deutsch"] = "de",+ ["zh"] = "zh",+ ["chinese"] = "zh",+ ["zh-cn"] = "zh",+ ["zh-tw"] = "zh",+ ["hi"] = "hi",+ ["hindi"] = "hi",+ ["हिन्दी"] = "hi",+ ["ja"] = "ja",+ ["japanese"] = "ja",+ ["日本語"] = "ja",+ ["ko"] = "ko",+ ["korean"] = "ko",+ ["한국어"] = "ko",+ ["ru"] = "ru",+ ["russian"] = "ru",+ ["русский"] = "ru",+ ["pt"] = "pt",+ ["portuguese"] = "pt",+ ["português"] = "pt",+ ["ar"] = "ar",+ ["arabic"] = "ar",+ ["العربية"] = "ar",+ ["ne"] = "ne",+ ["nepali"] = "ne",+ ["नेपाली"] = "ne",+ ["it"] = "it",+ ["italian"] = "it",+ ["italiano"] = "it",+ ["nl"] = "nl",+ ["dutch"] = "nl",+ ["nederlands"] = "nl",+ ["pl"] = "pl",+ ["polish"] = "pl",+ ["polski"] = "pl",+ ["tr"] = "tr",+ ["turkish"] = "tr",+ ["türkçe"] = "tr"+ };++ private static readonly Dictionary<string, string> CodeToNameMap = new(StringComparer.OrdinalIgnoreCase)+ {+ ["en"] = "English",+ ["es"] = "Spanish",+ ["fr"] = "French",+ ["de"] = "German",+ ["zh"] = "Chinese",+ ["hi"] = "Hindi",+ ["ja"] = "Japanese",+ ["ko"] = "Korean",+ ["ru"] = "Russian",+ ["pt"] = "Portuguese",+ ["ar"] = "Arabic",+ ["ne"] = "Nepali",+ ["it"] = "Italian",+ ["nl"] = "Dutch",+ ["pl"] = "Polish",+ ["tr"] = "Turkish"+ };+}diff --git a/src/Filee.Engines/Translation/TranslatorConverter.cs b/src/Filee.Engines/Translation/TranslatorConverter.csnew file mode 100644index 00000000..b0a09180--- /dev/null+++ b/src/Filee.Engines/Translation/TranslatorConverter.cs@@ -0,0 +1,322 @@+using System.Text;+using Filee.Core.Conversion;+using Filee.Core.Formats;+using Filee.Engines.Ebooks;+using Filee.Engines.Hwp;+using Filee.Engines.Hwp.Hwpx;+using Filee.Engines.Hwp.Hwpx.Docx;+using Filee.Engines.Infrastructure;+using Filee.Engines.Pdf;+using Microsoft.Extensions.Logging;+using PdfSharp;+using PdfSharp.Drawing;+using PdfSharp.Pdf;++namespace Filee.Engines.Translation;++/// <summary>+/// Digital document and e-book translator preserving layout, formatting, tags, images, and tables.+/// </summary>+public sealed class TranslatorConverter : IConverter+{+ private static readonly string[] DocumentFormats =+ [+ "epub", "kepub", "mobi", "azw3", "azw", "prc", "fb2", "htmlz", "txtz",+ "md", "txt", "html", "docx", "pdf", "hwpx", "json", "yaml", "toml", "xml", "srt", "vtt", "csv"+ ];++ private readonly ITranslationService? _translationService;+ private readonly ILogger? _logger;++ public TranslatorConverter(ILogger<TranslatorConverter>? logger = null)+ : this(null, logger)+ {+ }++ public TranslatorConverter(ITranslationService? translationService, ILogger<TranslatorConverter>? logger = null)+ {+ _translationService = translationService;+ _logger = logger;+ }++ public string Id => "translator";+ public string DisplayName => "Translator";+ public int MaxParallelism => 2;++ public IReadOnlyList<ConversionEdge> Edges { get; } =+ DocumentFormats.SelectMany(from =>+ DocumentFormats.Select(to => new ConversionEdge(from, to, from == to ? 10 : 12, Translate: true)))+ .ToList();++ public EngineStatus GetStatus()+ {+ if (_translationService is not null)+ return EngineStatus.Available("embedded", "Test Translator");++ try+ {+ using var client = new HttpClient { Timeout = TimeSpan.FromMilliseconds(300) };+ var res = client.GetAsync("http://127.0.0.1:11434/api/tags").GetAwaiter().GetResult();+ if (res.IsSuccessStatusCode)+ return EngineStatus.Available("http://127.0.0.1:11434", "Ollama (Local Offline)");+ }+ catch+ {+ // Local Ollama not running+ }++ if (TranslationService.LocateLocalEngine() is { } cli && File.Exists(cli))+ return EngineStatus.Available(cli, "Translator (Local)");++ return EngineStatus.Unavailable("engine.reason.download_translator");+ }++ public async Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken)+ {+ var status = GetStatus();+ if (!status.IsAvailable && _translationService is null)+ throw new ConversionRefusedException("error.translation_needs_engine");++ progress?.Report(0.05);+ var work = EbookFiles.NewFolder(step.WorkDirectory, "translate");+ var targetLang = step.Preset.Translate.TargetLanguage;+ var sourceLang = step.Preset.Translate.SourceLanguage;++ var service = _translationService ?? new TranslationService(step.Preset.Translate, logger: _logger);++ // 1. Read document / e-book into in-memory model+ progress?.Report(0.15);+ var (book, doc) = Read(step, work, cancellationToken);++ // 2. Translate text while preserving structural layout and inline tags+ progress?.Report(0.25);+ var transProgress = new Progress<double>(p => progress?.Report(0.25 + 0.65 * p));++ if (book is not null)+ {+ await DocumentTranslator.TranslateBookAsync(book, targetLang, sourceLang, service, transProgress, cancellationToken);+ }+ else if (doc is not null)+ {+ await DocumentTranslator.TranslateDocumentAsync(doc, targetLang, sourceLang, service, transProgress, cancellationToken);+ }++ // 3. Write out to requested target format+ progress?.Report(0.92);+ var ext = FormatRegistry.FindById(step.To)?.PrimaryExtension ?? step.To;+ var output = step.Output.Allocate(ext);+ if (output is null)+ return [];++ Write(book, doc, step, output, work, cancellationToken);+ progress?.Report(1.0);+ return [output];+ }++ private static (Book? Book, HDocument? Document) Read(ConversionStep step, string work, CancellationToken cancellationToken)+ {+ var input = step.InputPath;+ var media = Path.Combine(work, "media");+ Directory.CreateDirectory(media);++ switch (step.From)+ {+ case "epub" or "kepub":+ return (EpubReader.ReadBook(input, work, cancellationToken), null);+ case "mobi" or "azw3" or "azw" or "prc":+ return (MobiReader.ReadBook(input, work, cancellationToken), null);+ case "fb2":+ return (Fb2Reader.ReadBook(input, work), null);+ case "htmlz":+ return (ZippedText.ReadHtmlzBook(input, work, cancellationToken), null);+ case "txtz":+ return (ZippedText.ReadTxtzBook(input, work), null);+ case "html":+ {+ var document = HtmlReader.Read(input, media);+ return (new Book(document, new BookMetadata { Title = document.Title }), document);+ }+ case "md":+ {+ var text = HwpxConverter.DecodeText(File.ReadAllBytes(input));+ var document = MarkdownReader.Read(text, Path.GetDirectoryName(Path.GetFullPath(input))!);+ return (new Book(document, new BookMetadata { Title = document.Title }), document);+ }+ case "txt" or "json" or "yaml" or "toml" or "xml" or "srt" or "vtt" or "csv":+ {+ var text = HwpxConverter.DecodeText(File.ReadAllBytes(input));+ var document = PlainText.ToDocument(text);+ return (new Book(document, new BookMetadata()), document);+ }+ case "docx":+ {+ var document = DocxReader.Read(input, media);+ return (new Book(document, new BookMetadata { Title = document.Title }), document);+ }+ case "pdf":+ {+ var document = PdfDocumentReader.Read(input, media);+ return (new Book(document, new BookMetadata { Title = document.Title }), document);+ }+ default:+ throw new NotSupportedException($"Translation from format {step.From} is not supported.");+ }+ }++ private static void Write(Book? book, HDocument? doc, ConversionStep step, string output, string work, CancellationToken cancellationToken)+ {+ var document = doc ?? book?.Document ?? throw new InvalidOperationException("No document available to write.");+ var b = book ?? new Book(document, new BookMetadata { Title = document.Title });++ switch (step.To)+ {+ case "epub":+ EpubWriter.Write(b, output, step.InputPath, work);+ break;+ case "kepub":+ {+ var tempEpub = Path.Combine(work, "temp.epub");+ EpubWriter.Write(b, tempEpub, step.InputPath, work);+ Kepub.FromEpub(tempEpub, output, cancellationToken);+ break;+ }+ case "hwpx":+ HwpxWriter.Write(document, output);+ break;+ case "docx":+ DocxWriter.Write(document, output);+ break;+ case "txt" or "json" or "yaml" or "toml" or "xml" or "srt" or "vtt" or "csv":+ File.WriteAllText(output, PlainTextWriter.Write(document), new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));+ break;+ case "html":+ {+ var images = EbookFiles.NewFolder(work, "html-images");+ var page = XhtmlWriter.Write(document, new XhtmlOptions { ImageSource = path => DataUri(path, images) }).Single();+ File.WriteAllText(output, XhtmlWriter.Page(document.Title ?? "", page.Body, b.DisplayLanguage(), null, epub: false), new UTF8Encoding(false));+ break;+ }+ case "md":+ File.WriteAllText(output, MarkdownWriter.Write(document, _ => null), new UTF8Encoding(false));+ break;+ case "fb2":+ Fb2Writer.Write(b, output, step.InputPath, work);+ break;+ case "htmlz":+ ZippedText.WriteHtmlz(b, output, step.InputPath, work);+ break;+ case "txtz":+ ZippedText.WriteTxtz(b, output, step.InputPath, work);+ break;+ case "pdf":+ WritePdf(document, output, work, cancellationToken);+ break;+ default:+ throw new NotSupportedException($"Writing to format {step.To} is not supported.");+ }+ }++ private static void WritePdf(HDocument document, string output, string work, CancellationToken cancellationToken)+ {+ // 1. Try bundled rhwp (Filee's primary engine for HWPX -> PDF)+ var rhwp = EngineEnvironment.FindBundled("rhwp") is { } bundled+ ? EngineEnvironment.FirstExisting(Path.Combine(bundled, OperatingSystem.IsWindows() ? "rhwp.exe" : "rhwp"))+ : null;++ if (rhwp is not null && File.Exists(rhwp))+ {+ try+ {+ var tempHwpx = Path.Combine(work, $"doc-{Guid.NewGuid():N}.hwpx");+ HwpxWriter.Write(document, tempHwpx);+ var tempPdf = Path.Combine(work, $"rhwp-{Guid.NewGuid():N}.pdf");+ var result = ProcessRunner.RunAsync(rhwp, ["export-pdf", tempHwpx, "-o", tempPdf, .. RhwpInput.PdfOptions()], TimeSpan.FromMinutes(3), cancellationToken).GetAwaiter().GetResult();+ if (result.ExitCode == 0 && File.Exists(tempPdf) && new FileInfo(tempPdf).Length > 0)+ {+ File.Move(tempPdf, output, overwrite: true);+ return;+ }+ }+ catch+ {+ // Fall back+ }+ }++ // 2. Try LibreOffice if available+ var lo = EngineEnvironment.FindBundled("libreoffice") is { } loBundled+ ? EngineEnvironment.FirstExisting(Path.Combine(loBundled, OperatingSystem.IsWindows() ? "program/soffice.exe" : "program/soffice"))+ : null;+ lo ??= EngineEnvironment.FirstExisting(OperatingSystem.IsWindows() ? @"C:\Program Files\LibreOffice\program\soffice.exe" : "/usr/bin/soffice");++ if (lo is not null && File.Exists(lo))+ {+ try+ {+ var tempDocx = Path.Combine(work, $"doc-{Guid.NewGuid():N}.docx");+ DocxWriter.Write(document, tempDocx);+ var loOutDir = Path.Combine(work, $"lo-{Guid.NewGuid():N}");+ Directory.CreateDirectory(loOutDir);+ var result = ProcessRunner.RunAsync(lo, ["--headless", "--convert-to", "pdf", "--outdir", loOutDir, tempDocx], TimeSpan.FromMinutes(3), cancellationToken).GetAwaiter().GetResult();+ var produced = Directory.GetFiles(loOutDir, "*.pdf").FirstOrDefault();+ if (produced is not null && File.Exists(produced) && new FileInfo(produced).Length > 0)+ {+ File.Move(produced, output, overwrite: true);+ return;+ }+ }+ catch+ {+ // Fall back+ }+ }++ // 3. Fallback using SkiaSharp to ensure a valid PDF is always produced+ WritePdfFallback(document, output);+ }++ private static void WritePdfFallback(HDocument document, string output)+ {+ using var stream = File.Create(output);+ using var doc = SkiaSharp.SKDocument.CreatePdf(stream);+ var margin = 40f;+ var pageWidth = 595f;+ var pageHeight = 842f;++ using var font = new SkiaSharp.SKFont(SkiaSharp.SKTypeface.Default, 11);+ using var paint = new SkiaSharp.SKPaint { Color = SkiaSharp.SKColors.Black, IsAntialias = true };++ var text = PlainTextWriter.Write(document);+ var lines = text.Split(["\r\n", "\r", "\n"], StringSplitOptions.None);++ var y = margin;+ var canvas = doc.BeginPage(pageWidth, pageHeight);++ foreach (var line in lines)+ {+ if (y > pageHeight - margin)+ {+ doc.EndPage();+ canvas = doc.BeginPage(pageWidth, pageHeight);+ y = margin;+ }++ if (string.IsNullOrWhiteSpace(line))+ {+ y += 14f;+ continue;+ }++ canvas.DrawText(line, margin, y, SkiaSharp.SKTextAlign.Left, font, paint);+ y += 14f;+ }++ doc.EndPage();+ doc.Close();+ }++ private static string? DataUri(string path, string convertFolder) =>+ EbookFiles.CommonImage(path, convertFolder, gifAndSvg: true) is ({ } file, { } mediaType)+ ? $"data:{mediaType};base64,{System.Convert.ToBase64String(File.ReadAllBytes(file))}"+ : null;+}diff --git a/tests/Filee.Core.Tests/TranslateRouteTests.cs b/tests/Filee.Core.Tests/TranslateRouteTests.csnew file mode 100644index 00000000..a5c0e0d8--- /dev/null+++ b/tests/Filee.Core.Tests/TranslateRouteTests.cs@@ -0,0 +1,92 @@+using Filee.Core.Conversion;+using Filee.Core.Formats;+using Filee.Core.Presets;+using Filee.Core.Profiles;+using Filee.Core.Settings;+using Xunit;++namespace Filee.Core.Tests;++public class TranslateRouteTests+{+ private sealed class DummyTranslateConverter : IConverter+ {+ public string Id => "translator";+ public string DisplayName => "Translator";+ public int MaxParallelism => 1;++ public IReadOnlyList<ConversionEdge> Edges { get; } =+ [+ new("epub", "epub", Cost: 10, Translate: true),+ new("md", "md", Cost: 10, Translate: true),+ new("txt", "txt", Cost: 10, Translate: true),+ new("docx", "docx", Cost: 10, Translate: true),+ new("pdf", "pdf", Cost: 10, Translate: true),+ new("json", "json", Cost: 10, Translate: true),+ new("epub", "docx", Cost: 12, Translate: true),+ ];++ public Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken) =>+ Task.FromResult<IReadOnlyList<string>>([step.Output.Allocate(step.To) ?? ""]);++ public EngineStatus GetStatus() => EngineStatus.Available("Translate", "1.0");+ }++ [Fact]+ public void BuiltIn_translate_preset_has_translate_flag_and_targets_same_as_source()+ {+ var preset = BuiltInData.CreatePresets().FirstOrDefault(p => p.Id == "translate");+ Assert.NotNull(preset);+ Assert.True(preset.Translate.Enabled);+ Assert.Equal(BuiltInData.SameAsSource, preset.TargetFormat);+ Assert.Equal("en", preset.Translate.TargetLanguage);+ }++ [Theory]+ [InlineData("epub", true)]+ [InlineData("md", true)]+ [InlineData("txt", true)]+ [InlineData("docx", true)]+ [InlineData("pdf", true)]+ [InlineData("json", true)]+ [InlineData("yaml", true)]+ [InlineData("srt", true)]+ [InlineData("png", false)]+ [InlineData("mp4", false)]+ [InlineData("zip", false)]+ public void TranslatesDocument_recognizes_valid_document_ebook_and_text_formats(string format, bool expected)+ {+ var preset = new Preset+ {+ Id = "test-translate",+ Translate = { Enabled = true, TargetLanguage = "hi" }+ };++ Assert.Equal(expected, preset.TranslatesDocument(format));+ }++ [Fact]+ public void RoutePlanner_routes_to_translator_when_translate_flag_is_true()+ {+ var planner = new RoutePlanner([new DummyTranslateConverter()]);++ // Regular route without translate should return null (translate edges are excluded from normal routes)+ var normalRoute = planner.Plan("epub", "epub", translate: false);+ Assert.Null(normalRoute);++ // With translate: true, it finds the route+ var translateRoute = planner.Plan("epub", "epub", translate: true);+ Assert.NotNull(translateRoute);+ Assert.Equal("translator", translateRoute.Steps[0].Converter.Id);+ Assert.True(translateRoute.Steps[0].Translate);+ }++ [Fact]+ public void Fresh_install_profiles_offer_translate_on_back_face()+ {+ var profiles = BuiltInData.CreateProfiles();+ Assert.Contains("translate", profiles.First(p => p.Id == "ebooks").BackPresetIds!);+ Assert.Contains("translate", profiles.First(p => p.Id == "text").BackPresetIds!);+ Assert.Contains("translate", profiles.First(p => p.Id == "office").BackPresetIds!);+ }+}diff --git a/tests/Filee.Engines.Tests/TranslationIntegrationTests.cs b/tests/Filee.Engines.Tests/TranslationIntegrationTests.csnew file mode 100644index 00000000..5a83705f--- /dev/null+++ b/tests/Filee.Engines.Tests/TranslationIntegrationTests.cs@@ -0,0 +1,198 @@+using Filee.Core.Conversion;+using Filee.Core.Presets;+using Filee.Engines.Translation;+using PdfSharp.Pdf.IO;+using Xunit;++namespace Filee.Engines.Tests;++public class TranslationIntegrationTests+{+ private sealed class MockTranslationService : ITranslationService+ {+ public Task<string> TranslateTextAsync(string text, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default)+ {+ if (toLang == "hi")+ return Task.FromResult("हर यात्रा एक कदम से शुरू होती है (brother)");+ if (toLang == "es")+ return Task.FromResult("El zorro marrón rápido salta sobre el perro perezoso.");+ return Task.FromResult($"[brother in {toLang}] {text}");+ }++ public Task<IReadOnlyList<string>> TranslateBatchAsync(IReadOnlyList<string> texts, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default)+ {+ IReadOnlyList<string> res = texts.Select(t =>+ {+ if (toLang == "hi")+ return "हर कदम (brother)";+ if (toLang == "es")+ return "Texto traducido al español.";+ return $"[brother in {toLang}] {t}";+ }).ToList();+ return Task.FromResult(res);+ }+ }++ private sealed class TestOutputAllocator : IOutputAllocator+ {+ private readonly string _dir;+ public TestOutputAllocator(string dir) => _dir = dir;++ public string? Allocate(string extension, string? name = null) =>+ Path.Combine(_dir, $"output-{Guid.NewGuid():N}.{extension}");++ public string Reserve(string path) => path;+ public void Relinquish(string path) { }+ }++ [Fact]+ public async Task Translates_chinese_markdown_to_english_preserving_markdown_structure()+ {+ var tempDir = Path.Combine(Path.GetTempPath(), "filee-trans-" + Guid.NewGuid().ToString("N"));+ Directory.CreateDirectory(tempDir);+ try+ {+ var inputFile = Path.Combine(tempDir, "sample_zh.md");+ var inputContent = "# 桃园三结义\n\n东汉末年,天下大乱。\n\n- 刘备为兄\n- 关羽次之\n- 张飞为弟\n";+ await File.WriteAllTextAsync(inputFile, inputContent);++ var preset = new Preset+ {+ Id = "translate",+ TargetFormat = "md",+ Translate = { Enabled = true, TargetLanguage = "en", SourceLanguage = "zh-CN" }+ };++ var step = new ConversionStep(+ inputFile,+ "md",+ "md",+ preset,+ new TestOutputAllocator(tempDir),+ tempDir,+ Translate: true+ );++ var converter = new TranslatorConverter(new MockTranslationService());+ var outputs = await converter.ConvertAsync(step, null, default);++ Assert.Single(outputs);+ var translatedPath = outputs[0];+ Assert.True(File.Exists(translatedPath));++ var translatedContent = await File.ReadAllTextAsync(translatedPath);+ Assert.NotEmpty(translatedContent);++ // Structure must have headings and list bullets+ Assert.Contains("#", translatedContent);+ Assert.Contains("-", translatedContent);++ // Content check+ Assert.Contains("brother", translatedContent, StringComparison.OrdinalIgnoreCase);+ }+ finally+ {+ try { Directory.Delete(tempDir, true); } catch { }+ }+ }++ [Fact]+ public async Task Translates_english_markdown_to_hindi_preserving_markdown_structure()+ {+ var tempDir = Path.Combine(Path.GetTempPath(), "filee-trans-hi-" + Guid.NewGuid().ToString("N"));+ Directory.CreateDirectory(tempDir);+ try+ {+ var inputFile = Path.Combine(tempDir, "sample_en.md");+ var inputContent = "# The Great Journey\n\nEvery journey begins with a single step.\n\n- First step\n- Second step\n";+ await File.WriteAllTextAsync(inputFile, inputContent);++ var preset = new Preset+ {+ Id = "translate",+ TargetFormat = "md",+ Translate = { Enabled = true, TargetLanguage = "hi", SourceLanguage = "en" }+ };++ var step = new ConversionStep(+ inputFile,+ "md",+ "md",+ preset,+ new TestOutputAllocator(tempDir),+ tempDir,+ Translate: true+ );++ var converter = new TranslatorConverter(new MockTranslationService());+ var outputs = await converter.ConvertAsync(step, null, default);++ Assert.Single(outputs);+ var translatedPath = outputs[0];+ Assert.True(File.Exists(translatedPath));++ var translatedContent = await File.ReadAllTextAsync(translatedPath);+ Assert.NotEmpty(translatedContent);++ // Structure check+ Assert.Contains("#", translatedContent);+ Assert.Contains("-", translatedContent);++ // Hindi Devanagari characters check (\u0900 - \u097F)+ Assert.Contains(translatedContent, c => c >= '\u0900' && c <= '\u097F');+ }+ finally+ {+ try { Directory.Delete(tempDir, true); } catch { }+ }+ }++ [Fact]+ public async Task Translates_document_to_pdf_producing_valid_openable_pdf()+ {+ var tempDir = Path.Combine(Path.GetTempPath(), "filee-trans-pdf-" + Guid.NewGuid().ToString("N"));+ Directory.CreateDirectory(tempDir);+ try+ {+ var inputFile = Path.Combine(tempDir, "document.txt");+ var inputContent = "The Quick Brown Fox Jumps Over The Lazy Dog.\nThis is a sample document for translation into PDF.\n";+ await File.WriteAllTextAsync(inputFile, inputContent);++ var preset = new Preset+ {+ Id = "translate",+ TargetFormat = "pdf",+ Translate = { Enabled = true, TargetLanguage = "es", SourceLanguage = "en" }+ };++ var step = new ConversionStep(+ inputFile,+ "txt",+ "pdf",+ preset,+ new TestOutputAllocator(tempDir),+ tempDir,+ Translate: true+ );++ var converter = new TranslatorConverter(new MockTranslationService());+ var outputs = await converter.ConvertAsync(step, null, default);++ Assert.Single(outputs);+ var pdfPath = outputs[0];+ Assert.True(File.Exists(pdfPath));+ Assert.True(new FileInfo(pdfPath).Length > 0);++ // Verify that the PDF is genuine, uncorrupted, and can be opened by PDF readers+ var header = File.ReadAllBytes(pdfPath).Take(5).ToArray();+ Assert.Equal("%PDF-", System.Text.Encoding.ASCII.GetString(header));++ using var pdfDoc = PdfReader.Open(pdfPath, PdfDocumentOpenMode.Import);+ Assert.True(pdfDoc.PageCount > 0);+ }+ finally+ {+ try { Directory.Delete(tempDir, true); } catch { }+ }+ }+}diff --git a/tests/Filee.Engines.Tests/TranslationTests.cs b/tests/Filee.Engines.Tests/TranslationTests.csnew file mode 100644index 00000000..b779b3ac--- /dev/null+++ b/tests/Filee.Engines.Tests/TranslationTests.cs@@ -0,0 +1,77 @@+using Filee.Engines.Hwp.Hwpx;+using Filee.Engines.Translation;+using Xunit;++namespace Filee.Engines.Tests;++public class TranslationTests+{+ private sealed class MockTranslationService : ITranslationService+ {+ public Task<string> TranslateTextAsync(string text, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default)+ {+ return Task.FromResult($"[TRANSLATED_{toLang}] {text}");+ }++ public Task<IReadOnlyList<string>> TranslateBatchAsync(IReadOnlyList<string> texts, string toLang, string fromLang = "auto", CancellationToken cancellationToken = default)+ {+ IReadOnlyList<string> res = texts.Select(t => $"[TRANSLATED_{toLang}] {t}").ToList();+ return Task.FromResult(res);+ }+ }++ [Fact]+ public void Normalizes_language_names_and_codes()+ {+ Assert.Equal("hi", TranslationService.NormalizeLanguage("hindi"));+ Assert.Equal("hi", TranslationService.NormalizeLanguage("HI"));+ Assert.Equal("en", TranslationService.NormalizeLanguage("English"));+ Assert.Equal("zh", TranslationService.NormalizeLanguage("Chinese"));+ Assert.Equal("es", TranslationService.NormalizeLanguage("spanish"));+ Assert.Equal("fr", TranslationService.NormalizeLanguage("french"));+ }++ [Theory]+ [InlineData("gpt-oss:120b-cloud", true)]+ [InlineData("model-cloud", true)]+ [InlineData("llama3.2:cloud", true)]+ [InlineData("my-cloud-model:latest", true)]+ [InlineData("cloud/llama3", true)]+ [InlineData("llama3.2", false)]+ [InlineData("qwen2.5:3b", false)]+ [InlineData("mistral:7b-instruct", false)]+ [InlineData("gemma2:9b", false)]+ public void IsCloudModel_identifies_cloud_forwarding_tags(string modelName, bool expected)+ {+ Assert.Equal(expected, TranslationService.IsCloudModel(modelName));+ }++ [Fact]+ public async Task DocumentTranslator_preserves_inline_formatting()+ {+ var doc = new HDocument();+ var sec = new HSection();+ doc.Sections.Add(sec);++ var p = new HParagraph();+ p.Inlines.Add(new HText("Chapter 1: ", new HCharFormat()));+ p.Inlines.Add(new HText("The Beginning", new HCharFormat()));+ sec.Blocks.Add(p);++ var service = new MockTranslationService();+ await DocumentTranslator.TranslateDocumentAsync(doc, "hi", "en", service, null, default);++ Assert.Equal(2, p.Inlines.Count);+ Assert.True(p.Inlines[0] is HText t0 && !string.IsNullOrEmpty(t0.Text));+ }++ [Fact]+ public async Task TranslationService_throws_when_no_local_engine_is_available()+ {+ var service = new TranslationService();+ if (!await TranslationService.IsLocalOllamaAvailableAsync() && TranslationService.LocateLocalEngine() is null)+ {+ await Assert.ThrowsAsync<InvalidOperationException>(() => service.TranslateTextAsync("Hello", "es", "en"));+ }+ }+}