feat(ai): let users pick the translation target language (LC-688) #654
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/LC-688-translate-picker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Per-message Translate always targeted the viewer's UI locale (
current_lang_code), andi18n::language_nameonly mapses-> "Spanish" and everything else -> "English". So a viewer whose locale resolved toesalways got Spanish with no way to choose, and translating a message already in your own language returned it unchanged (looked broken). The target was coupled to the two shipped UI locales even though the LLM can translate into any language.Change
An in-block language picker. The Translate menu item still opens the translation block; that block now carries a language
<select>(English, Spanish, Chinese, Hindi, Arabic, Portuguese, French, German, Russian, Japanese, Korean, Italian). Changing it re-posts to the translate route with the chosen target and swaps the block in place.views::translate::TranslateTargettable +resolve_target(requested, viewer_locale)- a pure, unit-tested helper: prefers the picker's choice, else the viewer's locale (primary subtag, soes-MX->es), else English. The allowlist bounds what reaches the LLM prompt.langfrom an all-optionalForm(empty body ->None-> default), feedstarget.englishto the prompt, and caches per(message, target.code)so each language caches independently. Editing a message still invalidates all cached translations.TranslationFragmentcarries the target list + selected code;translation_block.htmlrenders the<select>. New i18n keyroom-msg-translate-language(en + es) for its aria-label.Tests
resolve_target_prefers_request_then_viewer_then_english.cargo fmt+clippyclean; Tailwind rebuild confirms the select classes resolve.🤖 Generated with Claude Code
https://claude.ai/code/session_01PBAyCesyqJkZ5JgixXf9Lf