feat: on-device translation of item text (P13b-2)#140
Merged
Conversation
Second half of P13b: a "Translate…" action on item detail translates an item's description + transcript into the user's language, fully on-device via ML Kit. No Google Play Services — language models download over HTTPS (~30 MB, English pivot) and run offline after — fitting the sideloaded posture. Translation is ephemeral (no cache/schema). - Deps: google_mlkit_translation + google_mlkit_language_id (MIT). - Engine seam: TranslationEngine + MlKitTranslationEngine (Android, OnDeviceTranslator + model manager + LanguageIdentifier) + UnavailableTranslationEngine + factory/provider; graceful off-Android. translateLanguageForCode (BCP↔TranslateLanguage); translateFailed code. - Flow: overflow Translate… → target picker (default app language, reusing the caption-language picker) → detect source → action-driven ~30 MB pack download confirm (Wi-Fi) → translate. A pure translateReadiness decision drives it. Screen-scoped itemTranslation(itemId) controller (autoDispose). - UI: description + transcript render translated with a "Translated from <src> · Show original" toggle. One-shot MetadataRepository.metadataForItem. - Tests: engine availability + BCP mapping, translateReadiness truth table, controller with a fake engine. No schema change. - Docs: P13-PLAN P13b-2 status, VERIFICATION P13b-2, SPEC deps, BACKLOG (translate summaries / cache / pack-management). https://claude.ai/code/session_013JoYmLCosYt5tQ8qwdbL1T
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Second half of P13b — on-device translation. A "Translate…" action on item detail translates an item's description + transcript into the user's language, fully on-device via ML Kit. No Google Play Services — language models download over HTTPS (~30 MB each, English pivot) and run offline after — fitting GrabBit's sideloaded/de-Googled posture. Translation is ephemeral (no cache, no schema change).
Changes
google_mlkit_translation+google_mlkit_language_id(both MIT), recorded indocs/SPEC.md.OcrEngine):TranslationEngine+MlKitTranslationEngine(Android —OnDeviceTranslator+OnDeviceTranslatorModelManager+LanguageIdentifier) +UnavailableTranslationEngine+ factory/provider; graceful off-Android. PuretranslateLanguageForCode(BCP↔TranslateLanguage); newtranslateFailederror code.translateReadinessdecision (unavailable/notDetected/alreadyInTarget/needsDownload/ready) drives it.itemTranslation(itemId)controller; description + transcript render translated with a "Translated from · Show original" toggle. Added a one-shotMetadataRepository.metadataForItem.Tests
dart formatclean ·flutter analyzeNo issues ·flutter test791 passed — including engine availability + BCP mapping, thetranslateReadinesstruth table, and the controller with a fakeTranslationEngine(translate populates description/transcript + langs;Show originaltoggle; description-only item). No schema change.Honest notes
StreamProvider.future, which timed out inProviderContainertests (the temporaryref.readsubscription was disposed before the drift stream emitted). Switched to a one-shotmetadataForItemread — correct for a command and reliably testable.This completes P13b's translation; P13b-3 (opt-in auto-OCR on download) remains a planned follow-up.
https://claude.ai/code/session_013JoYmLCosYt5tQ8qwdbL1T
Generated by Claude Code