From 01f3a71f0ae7375cd82f58ad35c384d4dadba25c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 27 Jun 2020 20:31:33 +1000 Subject: [PATCH] i18n today section --- rslib/ftl/statistics.ftl | 116 +++++++++++++++++---------------- ts/src/stats/TodayStats.svelte | 10 +-- ts/src/stats/graphs.css | 17 +---- ts/src/stats/today.ts | 51 ++++++++++----- 4 files changed, 99 insertions(+), 95 deletions(-) diff --git a/rslib/ftl/statistics.ftl b/rslib/ftl/statistics.ftl index a680613b2..9e0f22a40 100644 --- a/rslib/ftl/statistics.ftl +++ b/rslib/ftl/statistics.ftl @@ -3,75 +3,77 @@ statistics-due-date = Due # The count of cards waiting to be reviewed statistics-due-count = Due # Shown in the Due column of the Browse screen when the card is a new card -statistics-due-for-new-card = New #{$number} - +statistics-due-for-new-card = New #{ $number } ## eg 16.8s (3.6 cards/minute) -statistics-cards-per-min = {$cards-per-minute} cards/minute -statistics-average-answer-time = {$average-seconds}s ({ statistics-cards-per-min }) +statistics-cards-per-min = { $cards-per-minute } cards/minute +statistics-average-answer-time = { $average-seconds }s ({ statistics-cards-per-min }) ## A span of time studying took place in, for example ## "(studied 30 cards) in 3 minutes" -statistics-in-time-span-seconds = { $amount -> - [one] in {$amount} second - *[other] in {$amount} seconds - } - -statistics-in-time-span-minutes = { $amount -> - [one] in {$amount} minute - *[other] in {$amount} minutes - } - -statistics-in-time-span-hours = { $amount -> - [one] in {$amount} hour - *[other] in {$amount} hours - } - -statistics-in-time-span-days = { $amount -> - [one] in {$amount} day - *[other] in {$amount} days - } - -statistics-in-time-span-months = { $amount -> - [one] in {$amount} month - *[other] in {$amount} months - } - -statistics-in-time-span-years = { $amount -> - [one] in {$amount} year - *[other] in {$amount} years - } - -## - -statistics-cards = { $cards -> - [one] {$cards} card - *[other] {$cards} cards - } - +statistics-in-time-span-seconds = + { $amount -> + [one] in { $amount } second + *[other] in { $amount } seconds + } +statistics-in-time-span-minutes = + { $amount -> + [one] in { $amount } minute + *[other] in { $amount } minutes + } +statistics-in-time-span-hours = + { $amount -> + [one] in { $amount } hour + *[other] in { $amount } hours + } +statistics-in-time-span-days = + { $amount -> + [one] in { $amount } day + *[other] in { $amount } days + } +statistics-in-time-span-months = + { $amount -> + [one] in { $amount } month + *[other] in { $amount } months + } +statistics-in-time-span-years = + { $amount -> + [one] in { $amount } year + *[other] in { $amount } years + } +statistics-cards = + { $cards -> + [one] { $cards } card + *[other] { $cards } cards + } # a count of how many cards have been answered, eg "Total: 34 reviews" -statistics-reviews = { $reviews -> - [one] 1 review - *[other] {$reviews} reviews - } - +statistics-reviews = + { $reviews -> + [one] 1 review + *[other] { $reviews } reviews + } # Shown at the bottom of the deck list, and in the statistics screen. # eg "Studied 3 cards in 13 seconds today (4.33s/card)." # The { statistics-in-time-span-seconds } part should be pasted in from the English # version unmodified. statistics-studied-today = - Studied { statistics-cards } - { $unit -> - [seconds] { statistics-in-time-span-seconds } - [minutes] { statistics-in-time-span-minutes } - [hours] { statistics-in-time-span-hours } - [days] { statistics-in-time-span-days } - [months] { statistics-in-time-span-months } - *[years] { statistics-in-time-span-years } - } today - ({$secs-per-card}s/card) - + Studied { statistics-cards } + { $unit -> + [seconds] { statistics-in-time-span-seconds } + [minutes] { statistics-in-time-span-minutes } + [hours] { statistics-in-time-span-hours } + [days] { statistics-in-time-span-days } + [months] { statistics-in-time-span-months } + *[years] { statistics-in-time-span-years } + } today + ({ $secs-per-card }s/card) # eg, "Time taken to review card: 5s" statistics-seconds-taken = { $seconds }s +statistics-today-title = Today +statistics-today-again-count = Again count: +statistics-today-type-counts = Learn: { $learnCount }, Review: { $reviewCount }, Relearn: { $relearnCount }, Filtered: { $filteredCount } +statistics-today-no-cards = No cards have been studied today. +statistics-today-no-mature-cards = No mature cards were studied today. +statistics-today-correct-mature = Correct answers on mature cards: { $correct }/{ $total } ({ $percent }%) diff --git a/ts/src/stats/TodayStats.svelte b/ts/src/stats/TodayStats.svelte index fac9d9e0f..79fae5071 100644 --- a/ts/src/stats/TodayStats.svelte +++ b/ts/src/stats/TodayStats.svelte @@ -9,16 +9,18 @@ let todayData: TodayData | null = null; $: if (sourceData) { - console.log("gathering data"); todayData = gatherData(sourceData, i18n); } {#if todayData}
-

Today

+

{todayData.title}

-
{todayData.studiedToday}
- {JSON.stringify(todayData)} +
+ {#each todayData.lines as line} +
{line}
+ {/each} +
{/if} diff --git a/ts/src/stats/graphs.css b/ts/src/stats/graphs.css index 9587fcecc..0e7ada1ac 100644 --- a/ts/src/stats/graphs.css +++ b/ts/src/stats/graphs.css @@ -115,21 +115,6 @@ transition: opacity 1s; } -.tooltip-area { - height: 4em; -} - -.tooltip-area > * { - flex: 1 100%; - justify-content: center; - display: flex; -} - .legend-outer { - display: flex; - justify-content: center; -} - -.legend-outer div { - padding-left: 1em; + text-align: center; } diff --git a/ts/src/stats/today.ts b/ts/src/stats/today.ts index e5a7c6215..1c861d4c8 100644 --- a/ts/src/stats/today.ts +++ b/ts/src/stats/today.ts @@ -6,15 +6,8 @@ import { studiedToday } from "../time"; import { I18n } from "../i18n"; export interface TodayData { - correctCount: number; - matureCorrect: number; - matureCount: number; - learnCount: number; - reviewCount: number; - relearnCount: number; - earlyReviewCount: number; - - studiedToday: string; + title: string; + lines: string[]; } const ReviewKind = pb.BackendProto.RevlogEntry.ReviewKind; @@ -71,16 +64,38 @@ export function gatherData(data: pb.BackendProto.GraphsOut, i18n: I18n): TodayDa } } - const studiedTodayText = studiedToday(i18n, answerCount, answerMillis / 1000); + let lines: string[]; + if (answerCount) { + const studiedTodayText = studiedToday(i18n, answerCount, answerMillis / 1000); + const againCount = answerCount - correctCount; + let againCountText = i18n.tr(i18n.TR.STATISTICS_TODAY_AGAIN_COUNT); + againCountText += ` ${againCount} (${((againCount / answerCount) * 100).toFixed( + 2 + )}%)`; + const typeCounts = i18n.tr(i18n.TR.STATISTICS_TODAY_TYPE_COUNTS, { + learnCount, + reviewCount, + relearnCount, + filteredCount: earlyReviewCount, + }); + let matureText: string; + if (matureCount) { + matureText = i18n.tr(i18n.TR.STATISTICS_TODAY_CORRECT_MATURE, { + correct: matureCorrect, + total: matureCount, + percent: (matureCorrect / matureCount) * 100, + }); + } else { + matureText = i18n.tr(i18n.TR.STATISTICS_TODAY_NO_MATURE_CARDS); + } + + lines = [studiedTodayText, againCountText, typeCounts, matureText]; + } else { + lines = [i18n.tr(i18n.TR.STATISTICS_TODAY_NO_CARDS)]; + } return { - studiedToday: studiedTodayText, - correctCount, - matureCorrect, - matureCount, - learnCount, - reviewCount, - relearnCount, - earlyReviewCount, + title: i18n.tr(i18n.TR.STATISTICS_TODAY_TITLE), + lines, }; }