Skip to content

Fix #15760: Convert undo/redo labels to sentence case#20372

Open
flowerjunjie wants to merge 1 commit intoankidroid:mainfrom
flowerjunjie:fix/issue-15760
Open

Fix #15760: Convert undo/redo labels to sentence case#20372
flowerjunjie wants to merge 1 commit intoankidroid:mainfrom
flowerjunjie:fix/issue-15760

Conversation

@flowerjunjie
Copy link

This PR implements sentence case conversion for undo/redo labels to maintain consistency with the rest of the UI, as requested in #15760.

Changes

  • Added 120+ sentence case string resources for undo/redo actions
  • Created helper functions in SentenceCase.kt for undo/redo label conversion
  • Updated ReviewerViewModel.kt, Undo.kt, CardBrowser.kt, DeckPicker.kt, Reviewer.kt, StudyOptionsActivity.kt

Examples

Before After
Undo Empty Cards Undo empty cards
Empty Cards undone Empty cards undone

Fixes #15760

This commit implements sentence case conversion for undo/redo labels
to maintain consistency with the rest of the UI.

Changes:
- Added 120+ sentence case string resources for undo/redo actions
- Created helper functions in SentenceCase.kt for undo/redo label conversion
- Updated ReviewerViewModel.kt to convert undo/redo labels to sentence case
- Updated Undo.kt to convert undo/redo messages to sentence case
- Updated CardBrowser.kt, DeckPicker.kt, Reviewer.kt, StudyOptionsActivity.kt
to use sentence case for undo labels

The conversion handles patterns like:
- "Undo Empty Cards" → "Undo empty cards"
- "Empty Cards undone" → "Empty cards undone"
- "Redo Empty Cards" → "Redo empty cards"
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

* A map of Title Case action names to their sentence case resource IDs.
* Used for undo/redo label conversion.
*/
private val actionToSentenceCaseMap = mapOf(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you get these strings from?

Could you add the source to the commit message?

<string name="sentence_card_stats_previous_card_study">Previous card (study)</string>
<string name="sentence_actions_previous_card_info">Previous card info</string>

<!-- Undo/Redo strings - Issue #15760 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much duplication here IMO.

It would be much better to obtain the name of the action from GeneratedTranslations, which would mean this file does not need to be changed.

import com.ichi2.anki.ui.internationalization.redoneMessageToSentenceCase

suspend fun tryUndo(): String {
suspend fun tryUndo(context: Context): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context should not be a parameter here, this method should not have a direct Android dependency.

private suspend fun undo() {
Timber.v("ReviewerViewModel::undo")
actionFeedbackFlow.emit(tryUndo())
val context = AnkiDroidApp.instance.applicationContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context should not exist in a ViewModel, it's an Android concern.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design] Inconsistent String Casing

2 participants