Skip to content

Add translation infrastructure with Google Cloud and DeepL API support - #2

Open
fabian-st with Copilot wants to merge 5 commits into
masterfrom
copilot/add-translation-feature
Open

Add translation infrastructure with Google Cloud and DeepL API support#2
fabian-st with Copilot wants to merge 5 commits into
masterfrom
copilot/add-translation-feature

Conversation

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown

Implements core translation infrastructure allowing posts and comments to be translated via Google Cloud Translation or DeepL APIs. Users configure their translation backend and API credentials in settings.

Architecture

Translation Provider Pattern

public interface Translator {
    CompletableFuture<TranslationResult> translate(String text, String sourceLanguage, String targetLanguage);
    boolean isConfigured();
}
  • GoogleCloudTranslator - Google Cloud Translation API v2
  • DeepLTranslator - DeepL API (free/pro)
  • NoOpTranslator - Default when unconfigured
  • TranslatorProvider - Thread-safe singleton managing active backend

Data Model

  • Added translatedTitle, translatedSelfText, isTranslated to Post
  • Added translatedCommentRawText, isTranslated to Comment
  • Updated Parcelable serialization for both

Dependency Injection

  • TranslatorProvider provided via Dagger
  • Gson provider added to AppModule for JSON parsing
  • Base OkHttpClient used for API calls

UI Implementation

Settings Screen

  • Backend selection: None / Google Cloud / DeepL
  • API key inputs with password masking and bullet display
  • Target language picker (21 languages)

Translation Triggers

  • "Translate" button added to PostOptionsBottomSheetFragment
  • "Translate" button added to CommentMoreBottomSheetFragment
  • Event handlers wired to ViewPostDetailActivity

Security

  • API keys masked in UI (displayed as ••••••••)
  • Synchronized lazy initialization in TranslatorProvider
  • Response body null checks before parsing
  • CodeQL scan: 0 alerts

Implementation Status

Complete:

  • Translation API integration
  • Settings UI and storage
  • Data model extensions
  • UI entry points

Requires Follow-up:

  • Adapter logic to call translator.translate() and update UI
  • Per-subreddit settings (Room database schema)
  • Language selection dialog
  • Auto-translate preferences
  • Translation caching

The infrastructure enables translation with minimal additional work in adapter classes to activate the feature end-to-end.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/gradle-daemon-main-8.10.2.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/agents/gradle-instrumentation-agent-8.10.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.10.2 (dns block)
  • jitpack.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/gradle-daemon-main-8.10.2.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/agents/gradle-instrumentation-agent-8.10.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.10.2 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 12, 2026 16:03
… data model updates

Co-authored-by: fabian-st <67522364+fabian-st@users.noreply.github.com>
Co-authored-by: fabian-st <67522364+fabian-st@users.noreply.github.com>
Co-authored-by: fabian-st <67522364+fabian-st@users.noreply.github.com>
…protected API keys

Co-authored-by: fabian-st <67522364+fabian-st@users.noreply.github.com>
Copilot AI changed the title [WIP] Add translation functionality for posts and comments Add translation infrastructure with Google Cloud and DeepL API support Feb 12, 2026
Copilot AI requested a review from fabian-st February 12, 2026 16:17
@fabian-st
fabian-st marked this pull request as ready for review February 12, 2026 16:27
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.

2 participants