diff --git a/pylib/tools/rewrite_tr.py b/pylib/tools/rewrite_tr.py
index de626aed4..a6cc2f549 100644
--- a/pylib/tools/rewrite_tr.py
+++ b/pylib/tools/rewrite_tr.py
@@ -9,13 +9,13 @@ from re import Match
import stringcase
-TR_REF = re.compile(r"tr\(\s*TR.([^,) ]+),\s*([^)]+)\)")
+TR_REF = re.compile(r"i18n\.tr\(i18n\.TR\.([^,) ]+)\)")
def repl(m: Match) -> str:
- name = m.group(1).lower()
- args = m.group(2)
- return f"tr.{name}({args})"
+ name = stringcase.camelcase(m.group(1).lower())
+ #args = m.group(2)
+ return f"i18n.{name}()"
def update_py(path: str) -> None:
@@ -24,11 +24,12 @@ def update_py(path: str) -> None:
if buf != buf2:
open(path, "w").writelines(buf2)
print("updated", path)
+ #print(buf2)
for dirpath, dirnames, fnames in os.walk(os.environ["BUILD_WORKSPACE_DIRECTORY"]):
if "bazel-" in dirpath:
continue
for fname in fnames:
- if fname.endswith(".py"):
+ if fname.endswith(".ts"):
update_py(os.path.join(dirpath, fname))
diff --git a/ts/graphs/added.ts b/ts/graphs/added.ts
index 62f9c0e60..70fa24e22 100644
--- a/ts/graphs/added.ts
+++ b/ts/graphs/added.ts
@@ -99,11 +99,11 @@ export function buildHistogram(
const cardsPerDay = Math.round(totalInPeriod / periodDays);
const tableData = [
{
- label: i18n.tr(i18n.TR.STATISTICS_TOTAL),
+ label: i18n.statisticsTotal(),
value: i18n.tr(i18n.TR.STATISTICS_CARDS, { cards: totalInPeriod }),
},
{
- label: i18n.tr(i18n.TR.STATISTICS_AVERAGE),
+ label: i18n.statisticsAverage(),
value: i18n.tr(i18n.TR.STATISTICS_CARDS_PER_DAY, { count: cardsPerDay }),
},
];
@@ -115,7 +115,7 @@ export function buildHistogram(
): string {
const day = dayLabel(i18n, bin.x0!, bin.x1!);
const cards = i18n.tr(i18n.TR.STATISTICS_CARDS, { cards: bin.length });
- const total = i18n.tr(i18n.TR.STATISTICS_RUNNING_TOTAL);
+ const total = i18n.statisticsRunningTotal();
const totalCards = i18n.tr(i18n.TR.STATISTICS_CARDS, { cards: cumulative });
return `${day}:
${cards}
${total}: ${totalCards}`;
}
diff --git a/ts/graphs/buttons.ts b/ts/graphs/buttons.ts
index 2a59c5c3f..2275b2867 100644
--- a/ts/graphs/buttons.ts
+++ b/ts/graphs/buttons.ts
@@ -160,14 +160,14 @@ export function renderButtons(
let kind: string;
switch (d) {
case "learning":
- kind = i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS);
+ kind = i18n.statisticsCountsLearningCards();
break;
case "young":
- kind = i18n.tr(i18n.TR.STATISTICS_COUNTS_YOUNG_CARDS);
+ kind = i18n.statisticsCountsYoungCards();
break;
case "mature":
default:
- kind = i18n.tr(i18n.TR.STATISTICS_COUNTS_MATURE_CARDS);
+ kind = i18n.statisticsCountsMatureCards();
break;
}
return `${kind} \u200e(${totalCorrect(d).percent}%)`;
@@ -239,8 +239,8 @@ export function renderButtons(
// hover/tooltip
function tooltipText(d: Datum): string {
- const button = i18n.tr(i18n.TR.STATISTICS_ANSWER_BUTTONS_BUTTON_NUMBER);
- const timesPressed = i18n.tr(i18n.TR.STATISTICS_ANSWER_BUTTONS_BUTTON_PRESSED);
+ const button = i18n.statisticsAnswerButtonsButtonNumber();
+ const timesPressed = i18n.statisticsAnswerButtonsButtonPressed();
const correctStr = i18n.tr(
i18n.TR.STATISTICS_HOURS_CORRECT,
totalCorrect(d.group)
diff --git a/ts/graphs/card-counts.ts b/ts/graphs/card-counts.ts
index 19e63f752..d8ff6a12d 100644
--- a/ts/graphs/card-counts.ts
+++ b/ts/graphs/card-counts.ts
@@ -89,48 +89,38 @@ function countCards(
const extraQuery = separateInactive ? 'AND -("is:buried" OR "is:suspended")' : "";
const counts: Count[] = [
+ [i18n.statisticsCountsNewCards(), newCards, true, `"is:new"${extraQuery}`],
[
- i18n.tr(i18n.TR.STATISTICS_COUNTS_NEW_CARDS),
- newCards,
- true,
- `"is:new"${extraQuery}`,
- ],
- [
- i18n.tr(i18n.TR.STATISTICS_COUNTS_LEARNING_CARDS),
+ i18n.statisticsCountsLearningCards(),
learn,
true,
`(-"is:review" AND "is:learn")${extraQuery}`,
],
[
- i18n.tr(i18n.TR.STATISTICS_COUNTS_RELEARNING_CARDS),
+ i18n.statisticsCountsRelearningCards(),
relearn,
true,
`("is:review" AND "is:learn")${extraQuery}`,
],
[
- i18n.tr(i18n.TR.STATISTICS_COUNTS_YOUNG_CARDS),
+ i18n.statisticsCountsYoungCards(),
young,
true,
`("is:review" AND -"is:learn") AND "prop:ivl<21"${extraQuery}`,
],
[
- i18n.tr(i18n.TR.STATISTICS_COUNTS_MATURE_CARDS),
+ i18n.statisticsCountsMatureCards(),
mature,
true,
`("is:review" -"is:learn") AND "prop:ivl>=21"${extraQuery}`,
],
[
- i18n.tr(i18n.TR.STATISTICS_COUNTS_SUSPENDED_CARDS),
+ i18n.statisticsCountsSuspendedCards(),
suspended,
separateInactive,
'"is:suspended"',
],
- [
- i18n.tr(i18n.TR.STATISTICS_COUNTS_BURIED_CARDS),
- buried,
- separateInactive,
- '"is:buried"',
- ],
+ [i18n.statisticsCountsBuriedCards(), buried, separateInactive, '"is:buried"'],
];
return counts;
@@ -145,7 +135,7 @@ export function gatherData(
const counts = countCards(data.cards, separateInactive, i18n);
return {
- title: i18n.tr(i18n.TR.STATISTICS_COUNTS_TITLE),
+ title: i18n.statisticsCountsTitle(),
counts,
totalCards,
};
diff --git a/ts/graphs/ease.ts b/ts/graphs/ease.ts
index 20e02f9d4..fa9507099 100644
--- a/ts/graphs/ease.ts
+++ b/ts/graphs/ease.ts
@@ -112,7 +112,7 @@ export function prepareData(
const xTickFormat = (num: number): string => `${num.toFixed(0)}%`;
const tableData = [
{
- label: i18n.tr(i18n.TR.STATISTICS_AVERAGE_EASE),
+ label: i18n.statisticsAverageEase(),
value: xTickFormat(sum(allEases) / total),
},
];
diff --git a/ts/graphs/future-due.ts b/ts/graphs/future-due.ts
index a50bbb8d6..b6699602d 100644
--- a/ts/graphs/future-due.ts
+++ b/ts/graphs/future-due.ts
@@ -157,7 +157,7 @@ export function buildHistogram(
const cards = i18n.tr(i18n.TR.STATISTICS_CARDS_DUE, {
cards: binValue(bin as any),
});
- const totalLabel = i18n.tr(i18n.TR.STATISTICS_RUNNING_TOTAL);
+ const totalLabel = i18n.statisticsRunningTotal();
return `${days}:
${cards}
${totalLabel}: ${cumulative}`;
}
@@ -172,17 +172,17 @@ export function buildHistogram(
const periodDays = xMax! - xMin!;
const tableData = [
{
- label: i18n.tr(i18n.TR.STATISTICS_TOTAL),
+ label: i18n.statisticsTotal(),
value: i18n.tr(i18n.TR.STATISTICS_REVIEWS, { reviews: total }),
},
{
- label: i18n.tr(i18n.TR.STATISTICS_AVERAGE),
+ label: i18n.statisticsAverage(),
value: i18n.tr(i18n.TR.STATISTICS_REVIEWS_PER_DAY, {
count: Math.round(total / periodDays),
}),
},
{
- label: i18n.tr(i18n.TR.STATISTICS_DUE_TOMORROW),
+ label: i18n.statisticsDueTomorrow(),
value: i18n.tr(i18n.TR.STATISTICS_REVIEWS, {
reviews: sourceData.dueCounts.get(1) ?? 0,
}),
diff --git a/ts/graphs/intervals.ts b/ts/graphs/intervals.ts
index 1a383fe97..674834fe6 100644
--- a/ts/graphs/intervals.ts
+++ b/ts/graphs/intervals.ts
@@ -148,7 +148,7 @@ export function prepareIntervalData(
): string {
// const day = dayLabel(i18n, bin.x0!, bin.x1!);
const interval = intervalLabel(i18n, bin.x0!, bin.x1!, bin.length);
- const total = i18n.tr(i18n.TR.STATISTICS_RUNNING_TOTAL);
+ const total = i18n.statisticsRunningTotal();
return `${interval}
${total}: \u200e${percent.toFixed(1)}%`;
}
@@ -163,7 +163,7 @@ export function prepareIntervalData(
const meanIntervalString = timeSpan(i18n, meanInterval * 86400, false);
const tableData = [
{
- label: i18n.tr(i18n.TR.STATISTICS_AVERAGE_INTERVAL),
+ label: i18n.statisticsAverageInterval(),
value: meanIntervalString,
},
];
diff --git a/ts/graphs/reviews.ts b/ts/graphs/reviews.ts
index c2f94b5fc..3012df2d2 100644
--- a/ts/graphs/reviews.ts
+++ b/ts/graphs/reviews.ts
@@ -238,36 +238,20 @@ export function renderReviews(
const dayTotal = valueLabel(sum(totals));
let buf = `
${day} | ${dayTotal} |