Support AI translation for question and answer
Feature request
Add AI-assisted translation for question and answer drafts.
Requirements
- Allow users to translate question titles and content before submission.
- Allow users to translate answer content before submission.
- Preserve Markdown, code blocks, URLs, HTML, mentions, and placeholders.
- Use the configured AI provider, model, and site language.
- Provide an administrator setting to enable or disable translation.
- Handle provider errors with actionable messages.
- Keep translation opt-in at the editor level so users can review the generated draft before replacing their content.
/assign
Hi, I have some suggestions regarding the style and interaction:
-
Make the translation a small button placed at the end of the form.
-
Only display it when the input text does not match the target language.
-
After clicking, automatically replace the current form content with the translated text; there is no need for a modal to confirm, as the
<input>have a built-in undo function.
Hi @fenbox , thanks for the careful review and valuable feedback! Updated the PR to align with your suggestions.
- Added compact, Figma-aligned translation icons to title inputs and editor bottom-right corners.
- Shows “Translate into [language]” as the tooltip and accessible label.
- Added deterministic client-side language detection using franc-min.
- Shows the translation icon only when the input confidently differs from the site language.
- Handles short cross-script text and avoids guessing ambiguous same-script text.
- Ignores Markdown, code, URLs, HTML, mentions, and placeholders during detection.
- Debounces detection and lazy-loads franc-min.
- Removed the review modal.
- Translation now immediately replaces the relevant field while preserving undo/edit behavior.
- Added bottomRightAction to the editor to position the icon correctly.
- Added six language-detection tests.
Great news! Thank you for suggesting this feature. AI-assisted translation would be a valuable addition to Apache Answer, especially for multilingual communities. The ability to translate drafts while preserving Markdown, code blocks, URLs, and formatting would significantly improve accessibility and user experience. Looking forward to seeing this feature implemented!
