Conversation
8f8dc24 to
866bd15
Compare
| } | ||
| translationAvailabilityTask?.cancel() | ||
| translationAvailabilityTask = Task { @MainActor in | ||
| self.isTranslationAvailable = await self.checkIsTranslationAvailable() |
There was a problem hiding this comment.
It creates a little bit of a race condition, but in practice, it's extremely fast so it should not matter.
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 30332 | |
| Version | PR #25089 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 709dda4 | |
| Installation URL | 2ad5ddu6lpko8 |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 30332 | |
| Version | PR #25089 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 709dda4 | |
| Installation URL | 1pql2llb76eug |
| } | ||
|
|
||
| private lazy var _translationViewModel: Any = { | ||
| guard #available(iOS 26, *) else { return {} } |
There was a problem hiding this comment.
Not sure how I feel about this pattern... I guess it's fine, since the else block is dead code because the caller only runs on iOS 26+. But maybe there is another better (in terms of readability) way to code this?
|
|
||
| // Use continuation to wait for translation result | ||
| return try await withCheckedThrowingContinuation { continuation in | ||
| self.continuation = continuation |
There was a problem hiding this comment.
It seems a bit risky to hold the continuation instances at the class level, instead of locally in the function.
|
I couldn't get the translation to work. I can see the UI from the Translation framework, but after selecting languages, the app shows an "Unable to translate" error message. There are 100+ repeating error messages in Xcode console: |
I forgot to mention that it requires a physical device. Have you tried on a physical one or a sim? |
|
@kean Yes, I used my iPhone 16. I also downloaded the Chinese and English languages in the Translate app, which I don't think is necessary, but just in case. |
…it never restarts the translation if already started
|
I've tested a few other scenarios and found and fixed some issues:
I also opened the following issue: CMM-1107: Post translation in Reader sometimes breaks the HTML tags. I don't think there is an easy fix, so I'm not planning to address it in the scope of the PR. I've tested a couple of posts in Mandarin, and it worked for me. Would you mind sharing a post for which the translation fails? ScreenRecording_01-05-2026.18-11-50_1.MP4 |
|
The translation works on my iPhone now. What do you think about adding a button to revert back to the original content? |
crazytonyli
left a comment
There was a problem hiding this comment.
I still feel like the indirection between setting the configuration property to trigger the translation process and getting the translated result can be improved.
| guard #available(iOS 26, *) else { | ||
| return | ||
| } | ||
| let hostingController = UIHostingController(rootView: translationHostView) |
There was a problem hiding this comment.
It's annoying that the Translation framework does not support UIKit. What do you think about adding a comment here, saying this hidden UIHostingController view is used to present translation UI?
There was a problem hiding this comment.
It definitely is. I added a note.
| Color.clear | ||
| .frame(width: 0, height: 0) | ||
| .translationTask(viewModel.configuration) { session in | ||
| Task { @MainActor in |
There was a problem hiding this comment.
This Task is not needed.
I added a ticket CMM-1122: Add "Show Original" button for Reader translations. I hope I'll get to it, but I had to switch to a separate project for now. |
Yeah, I'm not completely happy with it, but there are just constraints to work around:
The only complication with the API added is that you also can't invoke it multiple times, which matches the underlying behavior of the Translation framework. |
|






Description
Closes CMM-745: On-device translation for posts.
Testing instructions
Recording
ScreenRecording_12-22-2025.16-58-08_1.MP4