Skip to content

Feat/translate autodetect batch#1275

Open
lrsierra wants to merge 5 commits intosukeesh:masterfrom
lrsierra:feat/translate-autodetect-batch
Open

Feat/translate autodetect batch#1275
lrsierra wants to merge 5 commits intosukeesh:masterfrom
lrsierra:feat/translate-autodetect-batch

Conversation

@lrsierra
Copy link
Copy Markdown

Title

translate: add auto-detect + multi-line batching (backward-compatible)

Description

This PR improves the translate plugin for common workflows while keeping existing behavior intact.

What changed

  • Auto-detect source: support src="auto" so users can omit the source language.
  • Multi-line batching: accept newline-separated text and return translations in the same order.
  • Large input safety: chunk long inputs (>10k chars) and reassemble; still prompt before saving to translated.txt.
  • No breaking changes: aliases and the step-by-step prompts remain unchanged.

Why
Reduce friction for quick translations (auto-detect) and lists/paragraphs (batch), without altering current UX.

Tests

  • test_translate_enhancements.py:

    • bonjour → hello
    • auto-detect succeeds when source omitted
    • order preserved for multi-line input
    • long input chunked and merged

Run:

source .venv/bin/activate
export PYTHONPATH="$PWD:$PWD/jarviscli"
python -m unittest jarviscli.tests.test_translate_enhancements -v

Manual check

translate
Enter source language 
auto
Enter destination language 
english
Enter text or path for file
hola
buenos días
adiós
# => three lines back, same order; optional save prompt

Files

  • jarviscli/plugins/translate.py
  • jarviscli/tests/test_translate_enhancements.py

Comment thread jarviscli/__main__.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these changes?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These updates make common translations faster by adding auto-detect and multi-line/batch handling while keeping the existing interactive flow unchanged. They also add safe chunking for long texts to avoid googletrans limits and preserve input order, plus clearer errors and optional save-to-file. I included unit tests and manual checks to show backward compatibility and verify the new paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants