Fix translations on Android using PROCESS_TEXT intent (#8486)

* use intents to translate text on android

* clean up config plugins

* restore day night plugin

just to be safe

* leave a comment for why we can't open translate directly

* add todo

* fix lockfile lint
This commit is contained in:
Samuel Newman
2025-08-11 18:37:39 +03:00
committed by GitHub
parent 2a6172cbaf
commit bb949e4f44
10 changed files with 120 additions and 53 deletions
@@ -0,0 +1,30 @@
const {withAndroidManifest} = require('@expo/config-plugins')
const withProcessTextQuery = config =>
// eslint-disable-next-line no-shadow
withAndroidManifest(config, config => {
const manifest = config.modResults.manifest
// Ensure <queries> stub exists
if (!manifest.queries) manifest.queries = [{}]
const queries = manifest.queries[0]
queries.intent = queries.intent || []
const exists = queries.intent.some(
i =>
i.action?.[0]?.$?.['android:name'] ===
'android.intent.action.PROCESS_TEXT',
)
if (!exists) {
queries.intent.push({
action: [{$: {'android:name': 'android.intent.action.PROCESS_TEXT'}}],
data: [{$: {'android:mimeType': 'text/plain'}}],
})
}
return config
})
module.exports = withProcessTextQuery