Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Comments

feat: EXPERIMENTAL in-browser post translation#1788

Open
SHAcollision wants to merge 4 commits intodevfrom
feat/translate-hook
Open

feat: EXPERIMENTAL in-browser post translation#1788
SHAcollision wants to merge 4 commits intodevfrom
feat/translate-hook

Conversation

@SHAcollision
Copy link
Contributor

This PR introduces an EXPERIMENTAL "Translate" button on posts.

Very experimental, opening a PR here only to share with you guys. Not intending to merge it, but we could eventually polish and merge.

image image

It uses the browser's built-in LanguageDetector and Translator APIs to provide on-device translations.

The feature automatically detects if a post's content is not in English and displays a "translate" button, allowing users to translate it.

The translation takes place in the user's browser using latest edge AI API recently presented by Google. There is no privacy concerns, data is always local. Translation quality is "acceptable" if the text is not difficult and has no typos. On first translation, the browser will fetch the language model, so it will take a few seconds showing the spinner.

Limitations

  • Browser Support: This is highly experimental and only works on very few supporting browsers (e.g., Chrome 138+).
  • Target Language: The translation target is currently hardcoded to English (en). Ideally, we read the target language from the user system or have a setting option to select language.

TODO

I leave these to you @flaviomoceri in case we decide we want to merge this feature:

  • Align the spinner, and make the "translate" button prettier.
  • Ideally display the detected language for all posts, e.g. es next to the translate button.
  • Allow target language to be other than en

@flaviomoceri flaviomoceri linked an issue Aug 1, 2025 that may be closed by this pull request
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add translation button in Pubky App

2 participants