Skip to content

test: detect R.string duplicates of backend translations#20535

Open
david-allison wants to merge 1 commit intoankidroid:mainfrom
david-allison:consolidate-translations
Open

test: detect R.string duplicates of backend translations#20535
david-allison wants to merge 1 commit intoankidroid:mainfrom
david-allison:consolidate-translations

Conversation

@david-allison
Copy link
Member

@david-allison david-allison commented Mar 21, 2026

Note

Assisted-by: Claude Opus 4.6

Code was written by Claude, with much re-prompting for comment formatting, abstractions and code changes
Code/comments were manually refactored and made less verbose


A number of my recent code reviews were flagging that strings added to R.string already exist in TR (GeneratedTranslations).

Approach

  • Iterate the English strings from both TR and R.string, and fail if there are duplicates not defined in one of two BASELINE_ variables
  • Produce copy-pasteable BASELINE text when the backend is updated

This test:

  • Automates my review comments
  • Produces copy-pasteable output to the BASELINE when the backend is updated
    • Allowing a fast fix of the test
  • Lists opportunities where we can remove duplicated strings
    • Reducing APK size
    • including .toSentenceCase() fixes
  • Ensures the baseline list is updated when strings are fixed

The format of BASELINE entries lists all the R.string and TR cases:
In some cases, there can be a many:many mapping, and a developer needs
to decide which to select:

* R.string.deck_conf_general | R.string.pref_cat_general
* TR.preferencesGeneral() | TR.schedulingGeneral()

How Has This Been Tested?

  • Test-only
  • Removed 2 strings from both BASELINEs and the test error provided the correct fix

Learning (optional, can help others)

  • Our editorConfig removed my nicely formatted comments
  • We had a LOT more strings than expected
    • BASELINE_DUPLICATES: 78
    • BASELINE_CASE_INSENSITIVE_DUPLICATES: 41

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

A number of my recent code reviews were flagging that strings added to R.string
already exist in `TR` (`GeneratedTranslations`).

To fix this, iterate the English strings from both TR and R.string, and fail
 if there are duplicates not defined in one of two BASELINE_ variables and
 produce copy-pasteable BASELINE text when the backend is updated

This test:
* Automates my review comments
* Produces copy-pasteable BASELINE text when the backend is updated
  * Allowing a fast fix of the test
* Lists opportunities where we can remove duplicated strings
  * Reducing APK size
  * Including `.toSentenceCase()` fixes
* Ensures the baseline list is updated when strings are fixed

The format of BASELINE entries lists all the `R.string` and `TR` cases:
 In some cases, there can be a many:many mapping, and a developer needs
 to decide which to select:

```
* R.string.deck_conf_general | R.string.pref_cat_general
* TR.preferencesGeneral() | TR.schedulingGeneral()
```

Assisted-by: Claude Opus 4.6

Code was written by Claude, with much re-prompting
 for comment formatting, abstractions and code changes
 Code/comments were manually refactored and made less verbose
@david-allison david-allison force-pushed the consolidate-translations branch from 8d49a4c to 11cfd78 Compare March 21, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant