Skip to content

Translate notes to user's preferred language - #1112

Open
albertotranquilli-cmyk wants to merge 1 commit into
PrimalHQ:mainfrom
albertotranquilli-cmyk:fix/1055-translate-notes
Open

albertotranquilli-cmyk wants to merge 1 commit into
PrimalHQ:mainfrom
albertotranquilli-cmyk:fix/1055-translate-notes

Conversation

@albertotranquilli-cmyk

Copy link
Copy Markdown

Summary

Closes #1055

Adds an X-style Translate control on notes so users can translate note content into their preferred language without copy-pasting into an external translator. Mirrors the approach in PrimalHQ/primal-web-app#229.

Behavior

  • Translate link under note body text (when content is non-empty)
  • Target language: device/app locale (Configuration.locales / Locale.getDefault())
  • Shows translated text under the original, with “Translated from {language}” + Show original
  • Note overflow menu: Translate Note opens Google Translate as a fallback

Translation API choice

  • Primary: Google Chrome public translate endpoint (clients5.google.com/translate_a/t?client=dict-chrome-ex) — no API key required
  • Fallback: MyMemory free public API (rate-limited)
  • Documented as unofficial / fragile; a future official Google/DeepL/LibreTranslate key on the backend would be more durable

Acceptance

  • Translate control on notes
  • Uses device/app locale as preferred language
  • Works without requiring Alberto’s API keys
  • Minimal, focused change (no new settings screen / provider config)
  • Unit tests for lang normalization + Google response parsing

Test plan

  • Open a feed note in a non-English device locale
  • Tap Translate → translated text appears
  • Tap Show original → translation panel hides
  • Overflow menu → Translate Note opens Google Translate with the note text
  • Empty / media-only notes hide the Translate control
  • :app:compileAospDebugKotlin succeeds
  • :app:testAospDebugUnitTest --tests NoteTranslateTest (8/8 passed)

Related

Closes PrimalHQ#1055. Mirrors the web Translate post control: Google Chrome
public translate endpoint with MyMemory fallback (no API keys), device
locale as target, overflow-menu Google Translate fallback, and unit
tests for lang/response helpers.
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.

Feature: Translate notes to user's preferred language

1 participant