FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve inline translation coverage by LuckyCoders · Pull Request #1600 · cheeaun/phanpy · GitHub

/ phanpy Public

Improve inline translation coverage - #1600

Open
LuckyCoders wants to merge 20 commits into
cheeaun:mainfrom
LuckyCoders:feat/auto-inline-translation
Open

LuckyCoders wants to merge 20 commits into
cheeaun:mainfrom
LuckyCoders:feat/auto-inline-translation

Conversation

LuckyCoders commented Sep 21, 2026
edited
Loading

Copy link
Copy Markdown

Summary

This PR adds automatic inline translation to the Phanpy timeline, open status conversations, and trending news cards.

The experience is similar to inline translation in X: when eligible content becomes visible, its translated text is shown directly in place. Phanpy keeps the original available through the translation icon, so users can switch between the translated and original versions without opening a separate translation block or leaving the feed.

The feature is designed for the Fediverse: it works with Phanpy's existing browser translation support or configured Translang-compatible instances, rather than requiring a single centralized translation backend.

What is included

  • Viewport-triggered automatic inline translation for timeline posts.
  • The same inline behavior for replies and nested replies in an open status conversation.
  • A translation/original toggle with the active state shown only while the translation is displayed.
  • Automatic translation of:
    • poll options;
    • image, GIF, video, and carousel/media descriptions;
    • profile bios (account.note);
    • long posts with media attachments or link previews when enabled;
    • trending news card titles and descriptions.
  • Trending news cards keep a compact layout and provide one translation/original toggle below each card instead of separate controls for the title and description.
  • Original clickable URLs are preserved in translated text.
  • Mentions and hashtags are protected from translation and restored as original clickable links.
  • Mention and hashtag markup is preserved (@/# prefix plus the underlined name/tag span), so translated content keeps the same visual styling as the original.
  • Media descriptions trigger a proper rerender when their translated value changes.
  • Profile bio translation controls are placed inside the bio block.
  • Added an opt-in setting for long posts with attachments so users can choose the extra translation workload.
  • Translated trending card titles and descriptions remain clamped to the same number of lines as their originals.

Translation flow

  1. A post, reply, or trending news card enters the viewport.
  2. Phanpy prepares the text while masking custom emojis, URLs, mentions, and hashtags where applicable.
  3. Translation uses the browser's built-in translator when supported, otherwise the configured Translang instance pool.
  4. Placeholders are restored as clickable original links, mentions, hashtags, and preserved markup.
  5. The translation is rendered inline and can be toggled back to the original where a toggle is provided.

This keeps translation convenient and immediate while remaining compatible with decentralized Mastodon/Fediverse deployments and multiple translation providers.

Verification

  • npm run build
  • npx oxfmt --check src/pages/trending.jsx src/components/translation-block.jsx src/components/links-bar.css
  • git diff --check
  • Manually verified in the local browser:
    • timeline post translation;
    • reply translation;
    • poll options;
    • media captions;
    • long post with attachment;
    • profile bio translation;
    • trending news card translation;
    • one original/translation toggle below each news card;
    • clickable URLs;
    • preserved @username and #hashtag links and styling;
    • switching between translation and original;
    • preserved line clamping for translated news-card text.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL