feat: added ability to translate articles with AI service#1072
Conversation
|
Enabled translation for #1070 |
spacecowboy
left a comment
There was a problem hiding this comment.
Tell your AI agent to stop touching comments and debug logging
|
Also CI is entirely broken. (you can ignore the apk-jobs, they always fail on PRs) |
|
When you write |
# Conflicts: # app/src/main/java/com/nononsenseapps/feeder/archmodel/SettingsStore.kt # app/src/main/java/com/nononsenseapps/feeder/model/opml/OPMLImporter.kt # app/src/test/java/com/nononsenseapps/feeder/model/opml/OpmlParserTest.kt # app/src/test/java/com/nononsenseapps/feeder/model/opml/OpmlWriterKtTest.kt
… previews' because it feels more precise to the actual behaviour
|
@spacecowboy Is my PR good, or would you like me to change something about it? |
…r translation APIs
|
@spacecowboy I removed the google translate API because it is harder to get. So now if you want test it completely, it is completely free. You just login to DeepL to get a free API key. |
spacecowboy
left a comment
There was a problem hiding this comment.
Added inline suggestions to use real ellipsis character.
Also, please have a look at CI results. You have both lint-errors and compilation errors.
fix lint by running ./gradlew ktlintformat
Co-authored-by: Jonas Kalderstam <[email protected]>
Co-authored-by: Jonas Kalderstam <[email protected]>
Co-authored-by: Jonas Kalderstam <[email protected]>
|
@spacecowboy okay, I made those changes. Let me know what you think! |
|
@spacecowboy Is there anything I need to change? My code is good as far as I know. |
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end translation support (fixing #1070) by introducing a dedicated “Translation API” configuration (currently DeepL-backed) alongside the existing summary AI integration, wiring the new preferences through settings UI + OPML import/export, and enabling translation of feed cards and full articles.
Changes:
- Split settings into “Summary API” vs “Translation API”, including provider selection/validation UX and new translation-related toggles.
- Implement DeepL translation/verification in
OpenAIApi, add translation caching + language-detection helpers viaTranslationManagerandTranslationLanguageUtils. - Integrate translation into feed previews and article viewing, and persist/import/export the new settings via OPML.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/test/java/com/nononsenseapps/feeder/openai/OpenAIApiTest.kt | Updates summary tests for new API signature and adds DeepL request/response tests with MockWebServer. |
| app/src/test/java/com/nononsenseapps/feeder/model/TranslationLanguageUtilsKtTest.kt | Adds unit tests for language matching and HTML stripping behavior used by translation detection. |
| app/src/test/java/com/nononsenseapps/feeder/model/opml/OpmlWriterKtTest.kt | Extends OPML writer test expectations to include translation-related settings. |
| app/src/test/java/com/nononsenseapps/feeder/model/opml/OpmlParserTest.kt | Extends OPML parser tests to verify translation settings are read/applied. |
| app/src/main/res/values/strings.xml | Adds new strings for translation UI, provider selection, and settings verification messages. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/SettingsViewModel.kt | Adds translation settings/toggles and refactors OpenAI settings event handling to support two sections. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/Settings.kt | Wires new view-state fields and renders summary + translation settings sections and translation default switches. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/settings/OpenAISection.kt | Adds provider presets, validation UX, and a dedicated translation section UI. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/FeedViewModel.kt | Adds feed-card translation state + orchestration using TranslationManager. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ArticleViewModel.kt | Adds article translation state, translation toggle action, and uses translation manager for translated content/TTS. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ArticleScreen.kt | Adds translate action to the article menu and shows a progress indicator while translating. |
| app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedScreen.kt | Merges translated feed-card previews into list/grid items and triggers translation when items appear. |
| app/src/main/java/com/nononsenseapps/feeder/openai/OpenAIApi.kt | Adds DeepL translate + verification support, updates summarization signature, and expands language parsing. |
| app/src/main/java/com/nononsenseapps/feeder/model/TranslationManager.kt | New translation manager handling caching, translation execution, and “already in target language” detection. |
| app/src/main/java/com/nononsenseapps/feeder/model/TranslationLanguageUtils.kt | New utilities for language detection preparation and target-language matching logic. |
| app/src/main/java/com/nononsenseapps/feeder/model/opml/OPMLImporter.kt | Imports new translation-related OPML settings into the settings store. |
| app/src/main/java/com/nononsenseapps/feeder/di/ArchModelModule.kt | Registers TranslationManager and updates OpenAIApi DI construction. |
| app/src/main/java/com/nononsenseapps/feeder/archmodel/SettingsStore.kt | Persists translation API settings, preferred translation language, and default translation toggles. |
| app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt | Exposes translation settings/toggles via repository APIs. |
| app/src/androidTest/java/com/nononsenseapps/feeder/model/opml/OPMLTest.kt | Extends instrumentation OPML test data/expectations with translation settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val translatedItem = translationManager.translateFeedListItem(item) | ||
| val updatedCached = | ||
| translationManager.getCachedTranslatedFeedListItem( | ||
| item = item, | ||
| settings = config.settings, | ||
| targetLanguage = config.targetLanguage, | ||
| ) |
spacecowboy
left a comment
There was a problem hiding this comment.
I think it seems good enough to merge
|
Thanks for the @JaredTweed and sorry about the long delayed review |
|
Thank you! |
|
Thanks for making this feature look forward to this in the next build! |
|
Is it possible to do this in a local way DeepL requires API and the option for google is not showing up for me could run a small model something like firefox does? @JaredTweed EDIT: did some digging and it looks like firefox uses the Bergamot with this behind it tool for their translations here is the how they use it if this is helpfull? |
|
@Digitalpeer1 Good idea! I will do that! |







Below are the screenshots associated with the update.
fixes #1070