diff --git a/scripts/android-app-i18n.ts b/scripts/android-app-i18n.ts index 0c65e6d6080b..31e3fff34f8b 100644 --- a/scripts/android-app-i18n.ts +++ b/scripts/android-app-i18n.ts @@ -7,9 +7,9 @@ import { NATIVE_I18N_LOCALES } from "./native-app-i18n.ts"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(HERE, ".."); -const ANDROID_ROOT = path.join(ROOT, "apps", "android", "app", "src", "main"); -const RESOURCE_ROOT = path.join(ANDROID_ROOT, "res"); -const SOURCE_ROOT = path.join(ANDROID_ROOT, "java"); +const ANDROID_MAIN_ROOT = path.join(ROOT, "apps", "android", "app", "src", "main"); +const RESOURCE_ROOT = path.join(ANDROID_MAIN_ROOT, "res"); +const SOURCE_ROOT = path.join(ANDROID_MAIN_ROOT, "java"); const INVENTORY_PATH = path.join(ROOT, "apps", ".i18n", "native-source.json"); const ARTIFACT_ROOT = path.join(ROOT, "apps", ".i18n", "native"); const TOOL_DISPLAY_PATH = path.join( @@ -205,15 +205,13 @@ async function readAndroidSource( return sources; } -async function readAndroidResourceReferences(root = ANDROID_ROOT): Promise { +async function readAndroidResourceReferences(root = ANDROID_MAIN_ROOT): Promise { const entries = await readdir(root, { withFileTypes: true }); const sources: string[] = []; for (const entry of entries) { const fullPath = path.join(root, entry.name); if (entry.isDirectory()) { - if (fullPath.startsWith(`${RESOURCE_ROOT}${path.sep}values`)) { - continue; - } + // This walk is confined to app/src/main, so Gradle build output is never eligible. sources.push(await readAndroidResourceReferences(fullPath)); continue; } diff --git a/test/scripts/android-app-i18n.test.ts b/test/scripts/android-app-i18n.test.ts index 277464b6bba4..0edae0bc55f6 100644 --- a/test/scripts/android-app-i18n.test.ts +++ b/test/scripts/android-app-i18n.test.ts @@ -26,8 +26,8 @@ describe("Android app i18n resources", () => { it("counts Kotlin and XML resource references", () => { expect( findUnusedAndroidResourceKeys( - ["kotlin_only", "manifest_only", "unused"], - 'R.string.kotlin_only android:label="@string/manifest_only"', + ["kotlin_only", "manifest_only", "values_only", "unused"], + 'R.string.kotlin_only android:label="@string/manifest_only" @string/values_only', ), ).toEqual(["unused"]); });