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.
This commit is contained in:
snowtimeglass 2025-09-17 09:07:31 +09:00
parent b97fb45e06
commit 6a1e5210c9
2 changed files with 14 additions and 13 deletions

View file

@ -46,15 +46,14 @@ studying-type-answer-unknown-field = Type answer: unknown field { $val }
studying-unbury = Unbury studying-unbury = Unbury
studying-what-would-you-like-to-unbury = What would you like to 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-you-havent-recorded-your-voice-yet = You haven't recorded your voice yet.
studying-card-studied-in = studying-card-studied-in-minute =
{ $count -> { $cards ->
[one] { $count } card studied in [one] { $cards } card
*[other] { $count } cards studied in *[other] { $cards } cards
} } studied in
studying-minute = { $minutes ->
{ $count -> [one] { $minutes } minute.
[one] { $count } minute. *[other] { $minutes } minutes.
*[other] { $count } minutes.
} }
studying-question-time-elapsed = Question time elapsed studying-question-time-elapsed = Question time elapsed
studying-answer-time-elapsed = Answer time elapsed studying-answer-time-elapsed = Answer time elapsed

View file

@ -966,11 +966,13 @@ timerStopped = false;
elapsed = self.mw.col.timeboxReached() elapsed = self.mw.col.timeboxReached()
if elapsed: if elapsed:
assert not isinstance(elapsed, bool) assert not isinstance(elapsed, bool)
part1 = tr.studying_card_studied_in(count=elapsed[1]) cards_val = elapsed[1]
mins = int(round(elapsed[0] / 60)) minutes_val = int(round(elapsed[0] / 60))
part2 = tr.studying_minute(count=mins) message = tr.studying_card_studied_in_minute(
cards=cards_val, minutes=str(minutes_val)
)
fin = tr.studying_finish() 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) diag.setIcon(QMessageBox.Icon.Information)
if diag.run() == fin: if diag.run() == fin:
self.mw.moveToState("deckBrowser") self.mw.moveToState("deckBrowser")