mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Make timebox message translatable with flexible variable order (#4338)
* Make timebox message translatable with flexible variable order Currently, the timebox dialog message is built from two separate strings, each containing one variable: "{ $count } cards studied in" + "{ $count } minutes." As a result, translators cannot freely reorder the variables in their translations. This change introduces a single string with both variables, allowing translators to adjust the order for more natural expressions in their languages. * Preserve old string for now * Ensure message doesn't display over two lines --------- Co-authored-by: Damien Elmes <gpg@ankiweb.net>
This commit is contained in:
parent
9e415869b8
commit
c2957746f4
2 changed files with 23 additions and 6 deletions
|
@ -46,6 +46,20 @@ studying-type-answer-unknown-field = Type answer: unknown field { $val }
|
|||
studying-unbury = Unbury
|
||||
studying-what-would-you-like-to-unbury = What would you like to unbury?
|
||||
studying-you-havent-recorded-your-voice-yet = You haven't recorded your voice yet.
|
||||
studying-card-studied-in-minute =
|
||||
{ $cards ->
|
||||
[one] { $cards } card
|
||||
*[other] { $cards } cards
|
||||
} studied in
|
||||
{ $minutes ->
|
||||
[one] { $minutes } minute.
|
||||
*[other] { $minutes } minutes.
|
||||
}
|
||||
studying-question-time-elapsed = Question time elapsed
|
||||
studying-answer-time-elapsed = Answer time elapsed
|
||||
|
||||
## OBSOLETE; you do not need to translate this
|
||||
|
||||
studying-card-studied-in =
|
||||
{ $count ->
|
||||
[one] { $count } card studied in
|
||||
|
@ -56,5 +70,3 @@ studying-minute =
|
|||
[one] { $count } minute.
|
||||
*[other] { $count } minutes.
|
||||
}
|
||||
studying-question-time-elapsed = Question time elapsed
|
||||
studying-answer-time-elapsed = Answer time elapsed
|
||||
|
|
|
@ -17,6 +17,7 @@ import aqt.browser
|
|||
import aqt.operations
|
||||
from anki.cards import Card, CardId
|
||||
from anki.collection import Config, OpChanges, OpChangesWithCount
|
||||
from anki.lang import with_collapsed_whitespace
|
||||
from anki.scheduler.base import ScheduleCardsAsNew
|
||||
from anki.scheduler.v3 import (
|
||||
CardAnswer,
|
||||
|
@ -966,11 +967,15 @@ timerStopped = false;
|
|||
elapsed = self.mw.col.timeboxReached()
|
||||
if elapsed:
|
||||
assert not isinstance(elapsed, bool)
|
||||
part1 = tr.studying_card_studied_in(count=elapsed[1])
|
||||
mins = int(round(elapsed[0] / 60))
|
||||
part2 = tr.studying_minute(count=mins)
|
||||
cards_val = elapsed[1]
|
||||
minutes_val = int(round(elapsed[0] / 60))
|
||||
message = with_collapsed_whitespace(
|
||||
tr.studying_card_studied_in_minute(
|
||||
cards=cards_val, minutes=str(minutes_val)
|
||||
)
|
||||
)
|
||||
fin = tr.studying_finish()
|
||||
diag = askUserDialog(f"{part1} {part2}", [tr.studying_continue(), fin])
|
||||
diag = askUserDialog(message, [tr.studying_continue(), fin])
|
||||
diag.setIcon(QMessageBox.Icon.Information)
|
||||
if diag.run() == fin:
|
||||
self.mw.moveToState("deckBrowser")
|
||||
|
|
Loading…
Reference in a new issue