Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

Change the word order of some of the toast messages

Open snowtimeglass opened this issue 3 years ago • 6 comments

Pull Request template

Purpose / Description

Anki Desktop uses the following word order pattern on some toast messages, for example, Card suspended.,

  1. Subject
  2. omission of be Verb
  3. Past participle

but it isn't used on some strings of AnkiDroid, for example, Suspended card. It is probably appropriate to use Anki Desktop's word order pattern on AnkiDroid as well.

image

Fixes

n/a

Approach

Change the strings on 02-strings.xml

How Has This Been Tested?

on my physical device imageimageimage imageimage image

Learning (optional, can help others)

n/a

Checklist

Please, go through these checks before submitting the PR.

  • [x] 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
  • [x] You have performed a self-review of your own code
  • [x] 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

snowtimeglass avatar Sep 19 '22 11:09 snowtimeglass

Message to maintainers, this PR contains strings changes.

  1. Before merging this PR, it is best to run the "Sync Translations" GitHub action, then make and merge a PR from the i18n_sync branch to get translations cleaned out.
  2. Then merge this PR, and immediately do another translation PR so the huge change made by this PR's key changes are all by themselves.

Read more about updating strings on the wiki,

github-actions[bot] avatar Sep 19 '22 11:09 github-actions[bot]

Actually, we have access to Anki Desktop strings, so we can reuse them directly. I'm on my phone right now, so I can't link the exact implementation on the moment, but if I recall correctly, it is on col.TR. So that is an option.

As the current PR only changes the English translation, I'd approve it, but I would like to see if the approach of reusing the Anki Desktop strings directly wouldn't be better

BrayanDSO avatar Sep 19 '22 17:09 BrayanDSO

Indeed - here's an example usage https://github.com/ankidroid/Anki-Android/pull/11740/files#diff-03de22cd624f1cb4006ae0c6622ec035f598d779dd1dfb64e2207f0a1824933cR42

And I just logged a couple items with regard to backend translation - it's all pretty new for us (#12452 + https://github.com/ankidroid/Anki-Android-Backend/issues/235)

mikehardy avatar Sep 19 '22 17:09 mikehardy

You can also use CollectionManager.TR(), which doesn't require an open collection or usage of withCol

dae avatar Sep 20 '22 01:09 dae

Here's how you could do it:

diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
index a13e4e352..c122b8bd8 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
@@ -50,6 +50,7 @@ import com.drakeet.drawer.FullDraggableContainer
 import com.google.android.material.snackbar.Snackbar
 import com.ichi2.anim.ActivityTransitionAnimation
 import com.ichi2.anim.ActivityTransitionAnimation.getInverseTransition
+import com.ichi2.anki.CollectionManager.TR
 import com.ichi2.anki.CollectionManager.withCol
 import com.ichi2.anki.UIUtils.showThemedToast
 import com.ichi2.anki.cardviewer.*
@@ -908,6 +909,15 @@ abstract class AbstractFlashcardViewer :
         }
     }
 
+    private fun showSnackbarWithUndoButtonText(
+        text: String,
+        duration: Int = Snackbar.LENGTH_SHORT
+    ) {
+        showSnackbarAboveAnswerButtons(text, duration) {
+            setAction(R.string.undo) { undo() }
+        }
+    }
+
     private fun getRecommendedEase(easy: Boolean): Int {
         return try {
             when (answerButtonCount) {
@@ -1648,7 +1658,7 @@ abstract class AbstractFlashcardViewer :
 
     internal fun buryCard(): Boolean {
         return dismiss(BuryCard(currentCard!!)) {
-            showSnackbarWithUndoButton(R.string.buried_card)
+            showSnackbarWithUndoButtonText(TR.studyingCardsBuried(1))
         }
     }
 

dae avatar Sep 20 '22 01:09 dae

Thank you all for the information and advice. I'll try :-D

snowtimeglass avatar Sep 20 '22 14:09 snowtimeglass

I would like to see if the approach of reusing the Anki Desktop strings directly wouldn't be better

@BrayanDSO I've tried the approach with CollectionManager.TR() as @dae taught me. image

My concern is that the approach makes inconsistency about punctuation between the reused messages and the other ones, at least for the moment. In general, the messages of AnkiDroid end without period as follows image while ones of Anki Desktop generally (maybe) end with it. image image

snowtimeglass avatar Sep 25 '22 14:09 snowtimeglass

Using Anki translations is something I prefer as it represents a more "shared work" future (between Anki Desktop and AnkiDroid), which may also be read as "less work per contributor" and is thus more sustainable long-term, even if there is punctuation inconsistency.

mikehardy avatar Sep 25 '22 15:09 mikehardy

Anyone can remove the dot on Poonton (Anki desktop translating platform) later. Sharing translations is the best path for consistency

BrayanDSO avatar Sep 25 '22 15:09 BrayanDSO

I see. Then, I'll continue this approach without so much concern about temporary inconsistency of punctuation.

About the approach, I have one question.

diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
-            showSnackbarWithUndoButton(R.string.buried_card)
+            showSnackbarWithUndoButtonText(TR.studyingCardsBuried(1))

For example, if the above replacement is done, should I delete <string name="buried_card">Card buried</string> in AnkiDroid/src/main/res/values/02-strings.xml?

snowtimeglass avatar Sep 25 '22 16:09 snowtimeglass

If the string isn't somewhere else, you can delete it. Actually, Lint will force will to delete it on this case.

BrayanDSO avatar Sep 25 '22 16:09 BrayanDSO

Thanks. Then, I guess I'd better leave it to Lint Debug to check if the string isn't somewhere else.

snowtimeglass avatar Sep 25 '22 16:09 snowtimeglass

After Bury note action is done, a message, for example, 2 cards buried., is shown on Anki Desktop. image

In order to reproduce it on AnkiDroid with Anki Desktop strings, what should be done? Filling in some variable in the following parentheses?

internal fun buryNote(): Boolean {
        return dismiss(BuryNote(currentCard!!)) {
            showSnackbarWithUndoButtonText(TR.studyingCardsBuried(●))

image

snowtimeglass avatar Oct 02 '22 16:10 snowtimeglass

On methods that operate on a note, you can use currentCard!!.note().numberOfCards(). If it operates on a card, passing 1 should be fine

BrayanDSO avatar Oct 02 '22 19:10 BrayanDSO

I see. Thanks a lot!

snowtimeglass avatar Oct 03 '22 13:10 snowtimeglass

@dae On Anki Desktop, the actions of Bury and Suspend produce messages whose styles are different from each other as follows. Is it intentional?

Action --> Message

Bury Card --> 1 card buried. Bury Note --> 2 cards buried. (the case of a note with 2 cards)

Suspend Card --> Card suspended. Suspend Note --> Note suspended.

snowtimeglass avatar Oct 03 '22 14:10 snowtimeglass

@dae good question for you just above :point_up:

mikehardy avatar Oct 13 '22 14:10 mikehardy

Sorry, lost track of this. I think the difference is just because they were added at different times by different people. Suspend card/note came earlier and is only used in the review screen; the bury message was added later, and including the number was likely because it can be used in both the reviewer and browse screen (even though the browse screen doesn't currently provide a bury option, it may in the future).

dae avatar Oct 14 '22 00:10 dae

@dae @mikehardy thanks. Then, I suppose the following hybrid style might be good.

Action --> Message

Bury Card --> Card buried. Bury Note --> n cards buried. (n≧2) ; 1 card buried. (the case of executing Bury Note gesture on a card which has no siblings. On AnkiDroid, Bury Note item itself on action menu isn't shown for the card)

Same for Suspend

Suspend Card --> Card suspended. Suspend Note --> n cards suspended. (n≧2) ; 1 card suspended. (the case of executing Suspend Note gesture on a card which has no siblings. On AnkiDroid, Suspend Note item itself on action menu isn't shown for the card)

May I continue working in this direction?

snowtimeglass avatar Oct 15 '22 15:10 snowtimeglass

Fine with me

BrayanDSO avatar Oct 15 '22 17:10 BrayanDSO

On Pontoon of Anki, the string of Card buried seems to exist only in AnkiMobile resource. image

What approach would be preferable? Using the string of AnkiMobile in some way? Requesting creation of that string in Anki Desktop resource? Just replacing <string name="buried_card">Buried card</string> with <string name="buried_card">Card buried</string> in AnkiDroid/src/main/res/values/02-strings.xml? Or replacing it with <string name="Card_buried">Card buried</string>?

snowtimeglass avatar Oct 23 '22 12:10 snowtimeglass

If we can use the mobile translation with CollectionManager.TR, use it

else if we have an AnkiDroid string equivalent to Card buried/Buried card, use it

else, create a new one on AnkiDroid

BrayanDSO avatar Oct 23 '22 18:10 BrayanDSO

The AnkiMobile translations are not easily usable. It's possible to migrate individual translations from mobile→desktop, but it's currently it's a bit of a pain to do so I'm afraid.

dae avatar Oct 24 '22 07:10 dae

Thank you, two. Then, rewriting the following related string on AnkiDroid is currently a handy way, I guess.

<string name="buried_card">Buried card</string>

snowtimeglass avatar Oct 24 '22 14:10 snowtimeglass

I've made strings (on 02-strings.xml in my local repository) for the snackbar message after the action of "Suspend note".

<!-- Reviewer actions -->
    <string name="card_buried">Card buried.</string>
    <plurals name="note_suspended">
        <item quantity="one">%d card suspended</item>
        <item quantity="other">%d cards suspended</item>
    </plurals>

Could anyone please advise me how to reflect the number of cards (%d) in the following code of AbstractFlashcardViewer.kt to show it on the snackbar message? Using getQuantityString and currentCard!!.note().numberOfCards()? (Currently, tapping "Suspend note" causes a crash on my debug.apk...)

    internal fun buryCard(): Boolean {
        return dismiss(BuryCard(currentCard!!)) {
            showSnackbarWithUndoButton(R.string.card_buried)
        }
    }

    internal fun buryNote(): Boolean {
        return dismiss(BuryNote(currentCard!!)) {
            showSnackbarWithUndoButtonText(TR.studyingCardsBuried(currentCard!!.note().numberOfCards()))
        }
    }

    internal fun suspendCard(): Boolean {
        return dismiss(SuspendCard(currentCard!!)) {
            showSnackbarWithUndoButtonText(TR.studyingCardSuspended())
        }
    }

    internal fun suspendNote(): Boolean {
        return dismiss(SuspendNote(currentCard!!)) {
            showSnackbarWithUndoButton(R.plurals.note_suspended)
        }
    }

snowtimeglass avatar Nov 13 '22 17:11 snowtimeglass

The results of the last commits are as follows. I would deeply appreciate it if you would give me a review and some advice. image image image image

snowtimeglass avatar Jan 22 '23 07:01 snowtimeglass

Hello 👋, this PR has been opened for more than 1 month with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

github-actions[bot] avatar Feb 21 '23 15:02 github-actions[bot]

Thank you so much for taking the trouble to do the review and the works!

snowtimeglass avatar Feb 23 '23 09:02 snowtimeglass

I'm clearing strings out now then will merge the strings-related stack of PRs queued up

mikehardy avatar Mar 25 '23 23:03 mikehardy

Hi there @snowtimeglass! This is the OpenCollective Notice for PRs merged from 2023-03-01 through 2023-03-31

If you are interested in compensation for this work, the process with details is here:

https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid

We only post one comment per person per month to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for this month

Please note that GSoC contributions are okay for this process. Our philosophy is that our users have donated to AnkiDroid for all contributions. The only PRs that will not go through the OpenCollective process are ones directly related to am accepted GSoC project from a selected participant, since those receive a stipend from GSoC itself.

Please understand that our monthly budget is never guaranteed to cover all claims - the cap on payments-per-person may be lower, but we try to make our process as fair and transparent as possible, we just need your understanding.

Thanks!

github-actions[bot] avatar May 18 '23 16:05 github-actions[bot]