Skip to content

Preserve hyperlink entities during alternative translations#17

Merged
Rocket-Space merged 1 commit intomasterfrom
codex/preserve-hyperlinks-in-translations
Feb 25, 2026
Merged

Preserve hyperlink entities during alternative translations#17
Rocket-Space merged 1 commit intomasterfrom
codex/preserve-hyperlinks-in-translations

Conversation

@Rocket-Space
Copy link
Owner

Motivation

  • Ensure that hyperlinks and link-like MessageEntity objects remain clickable and correctly positioned when using alternative translation providers that return plain text.
  • Avoid losing link semantics when the translator reorders or alters sentence structure by masking/restoring links around translation.

Description

  • Added alternativeTranslateWithEntities in TranslateAlert2 which masks link entities with placeholders, calls the alternative translator, and restores both visible text and MessageEntity instances into the translated result using preprocess.
  • Implemented helper types and functions: PlaceholderLink, isLinkEntity, and cloneLinkEntity to manage masking and recreation of link entities in the target text.
  • Updated translateAlt() in TranslateAlert2 to use the new entity-preserving flow and to build a Spannable via MessageObject.addEntitiesToText(...) so links remain interactive in the UI.
  • Updated TranslateController batching/fallback paths to call TranslateAlert2.alternativeTranslateWithEntities(...) for provider-based translations and removed an unused import (SpaceGramTranslator) from TranslateController.

Testing

  • Attempted a local Java build with ./gradlew -q :TMessagesProj:compileDebugJavaWithJavac, but it failed due to an environment JDK/Gradle mismatch (Unsupported class file major version 69), so full compile-time verification could not be completed here.
  • Performed static code edits and committed the changes (git commit completed) and created the PR; no unit/integration tests were run in this environment due to the build failure.

Codex Task

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Rocket-Space Rocket-Space merged commit 46f4d4e into master Feb 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant