Rename i18n and i18n_helpers to i18n-generated and i18n

- This way, we can restrict the awkwardness of importing files outside
  the ts directory within lib
This commit is contained in:
Henrik Giesel 2021-10-02 23:34:03 +02:00
parent e1d4292ce3
commit 51af6b2544
63 changed files with 110 additions and 121 deletions

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import NotetypeSelector from "./NotetypeSelector.svelte";
import Mapper from "./Mapper.svelte";
import { ChangeNotetypeState, MapContext } from "./lib";

View file

@ -3,8 +3,8 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import MapperRow from "./MapperRow.svelte";
import { tr } from "../lib/i18n";
import { ChangeNotetypeState, MapContext } from "./lib";
import { slide } from "svelte/transition";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import type { ChangeNotetypeState } from "./lib";
import { withButton } from "../components/helpers";

View file

@ -6,7 +6,7 @@
*/
import { ChangeNotetypeState, getChangeNotetypeInfo, getNotetypeNames } from "./lib";
import { setupI18n, ModuleName } from "../lib/i18n";
import { setupI18n, tr } from "../lib/i18n";
import { checkNightMode } from "../lib/nightmode";
import ChangeNotetypePage from "./ChangeNotetypePage.svelte";
import { nightModeKey } from "../components/context-keys";
@ -20,7 +20,7 @@ export async function changeNotetypePage(
getChangeNotetypeInfo(oldNotetypeId, newNotetypeId),
getNotetypeNames(),
setupI18n({
modules: [ModuleName.ACTIONS, ModuleName.CHANGE_NOTETYPE],
modules: [tr.ModuleName.ACTIONS, tr.ModuleName.CHANGE_NOTETYPE],
}),
]);

View file

@ -6,9 +6,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { Scheduler } from "../lib/proto";
import { buildNextLearnMsg } from "./lib";
import { bridgeLink } from "../lib/bridgecommand";
import { tr } from "../lib/i18n";
export let info: Scheduler.CongratsInfoResponse;
import * as tr from "../lib/i18n";
const congrats = tr.schedulingCongratulationsFinished();
let nextLearnMsg: string;

View file

@ -2,14 +2,14 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { getCongratsInfo } from "./lib";
import { setupI18n, ModuleName } from "../lib/i18n";
import { setupI18n, tr } from "../lib/i18n";
import { checkNightMode } from "../lib/nightmode";
import CongratsPage from "./CongratsPage.svelte";
export async function congrats(target: HTMLDivElement): Promise<void> {
checkNightMode();
await setupI18n({ modules: [ModuleName.SCHEDULING] });
await setupI18n({ modules: [tr.ModuleName.SCHEDULING] });
const info = await getCongratsInfo();
const page = new CongratsPage({
target,

View file

@ -4,8 +4,7 @@
import { Scheduler } from "../lib/proto";
import { postRequest } from "../lib/postrequest";
import { naturalUnit, unitAmount, unitName } from "../lib/time";
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
export async function getCongratsInfo(): Promise<Scheduler.CongratsInfoResponse> {
return Scheduler.CongratsInfoResponse.decode(

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import SwitchRow from "./SwitchRow.svelte";

View file

@ -3,10 +3,10 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import SwitchRow from "./SwitchRow.svelte";
import { tr } from "../lib/i18n";
import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState;

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import TooltipLabel from "./TooltipLabel.svelte";
import RevertButton from "./RevertButton.svelte";
import Row from "./Row.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import { getContext } from "svelte";
import { modalsKey } from "../components/context-keys";
import type { DeckOptionsState, ConfigListEntry } from "./lib";

View file

@ -3,7 +3,7 @@
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import EnumSelectorRow from "./EnumSelectorRow.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import StepsInputRow from "./StepsInputRow.svelte";

View file

@ -3,14 +3,15 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import StepsInputRow from "./StepsInputRow.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte";
import EnumSelectorRow from "./EnumSelectorRow.svelte";
import Warning from "./Warning.svelte";
import type { DeckOptionsState } from "./lib";
import { tr } from "../lib/i18n";
export let state: DeckOptionsState;
export let api = {};

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import type Dropdown from "bootstrap/js/dist/dropdown";
import WithDropdown from "../components/WithDropdown.svelte";
import DropdownMenu from "../components/DropdownMenu.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import { createEventDispatcher } from "svelte";
import type { DeckOptionsState } from "./lib";
import type Dropdown from "bootstrap/js/dist/dropdown";

View file

@ -3,11 +3,11 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte";
import SwitchRow from "./SwitchRow.svelte";
import { tr } from "../lib/i18n";
import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState;

View file

@ -8,7 +8,7 @@
import "../sveltelib/export-runtime";
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
import { setupI18n, ModuleName } from "../lib/i18n";
import { setupI18n, tr } from "../lib/i18n";
import { checkNightMode } from "../lib/nightmode";
import DeckOptionsPage from "./DeckOptionsPage.svelte";
import { nightModeKey, touchDeviceKey, modalsKey } from "../components/context-keys";
@ -21,9 +21,9 @@ export async function deckOptions(
getDeckOptionsInfo(deckId),
setupI18n({
modules: [
ModuleName.SCHEDULING,
ModuleName.ACTIONS,
ModuleName.DECK_CONFIG,
tr.ModuleName.SCHEDULING,
tr.ModuleName.ACTIONS,
tr.ModuleName.DECK_CONFIG,
],
}),
]);

View file

@ -9,7 +9,7 @@ import { DeckConfig } from "../lib/proto";
import { postRequest } from "../lib/postrequest";
import { Writable, writable, get, Readable, readable } from "svelte/store";
import { isEqual, cloneDeep } from "lodash-es";
import * as tr from "../lib/i18n";
import { i18n } from "../lib/i18n";
import type { DynamicSvelteComponent } from "../sveltelib/dynamicComponent";
export async function getDeckOptionsInfo(
@ -279,7 +279,7 @@ export class DeckOptionsState {
};
});
list.sort((a, b) =>
a.name.localeCompare(b.name, tr.i18n.langs, { sensitivity: "base" })
a.name.localeCompare(b.name, i18n.langs, { sensitivity: "base" })
);
return list;
}

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
export const reviewMixChoices = (): string[] => [
tr.deckConfigReviewMixMixWithReviews(),

View file

@ -3,12 +3,11 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import IconButton from "../components/IconButton.svelte";
import WithShortcut from "../components/WithShortcut.svelte";
import OnlyEditable from "./OnlyEditable.svelte";
import { tr } from "../lib/i18n";
import { withButton } from "../components/helpers";
import { ellipseIcon } from "./icons";
import { forEditorField } from ".";

View file

@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import IconButton from "../components/IconButton.svelte";
@ -13,6 +11,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import WithColorHelper from "./WithColorHelper.svelte";
import OnlyEditable from "./OnlyEditable.svelte";
import { tr } from "../lib/i18n";
import { bridgeCommand } from "../lib/bridgecommand";
import { withButton } from "../components/helpers";
import { textColorIcon, highlightColorIcon, arrowIcon } from "./icons";

View file

@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import IconButton from "../components/IconButton.svelte";
@ -14,6 +12,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import OnlyEditable from "./OnlyEditable.svelte";
import CommandIconButton from "./CommandIconButton.svelte";
import { tr } from "../lib/i18n";
import { getListItem } from "../lib/dom";
import { getCurrentField, execCommand } from "./helpers";
import {

View file

@ -3,12 +3,11 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import CommandIconButton from "./CommandIconButton.svelte";
import { tr } from "../lib/i18n";
import {
boldIcon,
italicIcon,

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte";

View file

@ -3,12 +3,11 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import IconButton from "../components/IconButton.svelte";
import { tr } from "../lib/i18n";
import { inlineIcon, blockIcon } from "./icons";
export let activeImage: HTMLImageElement;

View file

@ -4,7 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import { bridgeCommand } from "../lib/bridgecommand";
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import { withButton } from "../components/helpers";
import ButtonGroup from "../components/ButtonGroup.svelte";

View file

@ -4,7 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import { bridgeCommand } from "../lib/bridgecommand";
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import { withButton } from "../components/helpers";
import WithShortcut from "../components/WithShortcut.svelte";

View file

@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import { bridgeCommand } from "../lib/bridgecommand";
import { fieldFocusedKey, inCodableKey } from "./context-keys";

View file

@ -13,7 +13,7 @@ import type EditorToolbar from "./EditorToolbar.svelte";
import type TagEditor from "./TagEditor.svelte";
import { filterHTML } from "../html-filter";
import { setupI18n, ModuleName } from "../lib/i18n";
import { setupI18n, tr } from "../lib/i18n";
import { isApplePlatform } from "../lib/platform";
import { registerShortcut } from "../lib/shortcuts";
import { bridgeCommand } from "../lib/bridgecommand";
@ -200,10 +200,10 @@ export function setTags(tags: string[]): void {
export const i18n = setupI18n({
modules: [
ModuleName.EDITING,
ModuleName.KEYBOARD,
ModuleName.ACTIONS,
ModuleName.BROWSING,
tr.ModuleName.EDITING,
tr.ModuleName.KEYBOARD,
tr.ModuleName.ACTIONS,
tr.ModuleName.BROWSING,
],
});

View file

@ -2,8 +2,7 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { EditorField } from "./editor-field";
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
import { registerShortcut } from "../lib/shortcuts";
import { bridgeCommand } from "./lib";
import { appendInParentheses } from "./helpers";

View file

@ -13,6 +13,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import GraphRangeRadios from "./GraphRangeRadios.svelte";
import TableData from "./TableData.svelte";
import { tr } from "../lib/i18n";
import { RevlogRange, GraphRange } from "./graph-helpers";
import type { TableDatum, SearchEventMap } from "./graph-helpers";
import type { HistogramData } from "./histogram-graph";
@ -20,7 +21,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { GraphData } from "./added";
export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>;
let histogramData = null as HistogramData | null;

View file

@ -4,6 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import type { Stats } from "../lib/proto";
import { tr } from "../lib/i18n";
import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte";
@ -15,7 +16,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { defaultGraphBounds, GraphRange, RevlogRange } from "./graph-helpers";
export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let revlogRange: RevlogRange;
let graphRange: GraphRange = GraphRange.Year;

View file

@ -3,10 +3,10 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import { createEventDispatcher } from "svelte";
import type { Stats } from "../lib/proto";
import type { PreferenceStore } from "../sveltelib/preferences";
import { createEventDispatcher } from "svelte";
import { tr } from "../lib/i18n";
import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte";
@ -21,7 +21,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let sourceData: Stats.GraphsResponse;
export let preferences: PreferenceStore<Stats.GraphPreferences>;
export let revlogRange: RevlogRange;
import * as tr from "../lib/i18n";
export let nightMode: boolean;
let { calendarFirstDayOfWeek } = preferences;

View file

@ -3,20 +3,19 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import { createEventDispatcher } from "svelte";
import type { Stats } from "../lib/proto";
import type { PreferenceStore } from "../sveltelib/preferences";
import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte";
import { createEventDispatcher } from "svelte";
import type { Stats } from "../lib/proto";
import type { PreferenceStore } from "../sveltelib/preferences";
import { tr as trI18n } from "../lib/i18n";
import { defaultGraphBounds } from "./graph-helpers";
import type { SearchEventMap } from "./graph-helpers";
import { gatherData, renderCards } from "./card-counts";
import type { GraphData, TableDatum } from "./card-counts";
export let sourceData: Stats.GraphsResponse;
import * as tr2 from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>;
let { cardCountsSeparateInactive, browserLinksSupported } = preferences;
@ -36,8 +35,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
tableData = renderCards(svg as any, bounds, graphData);
}
const label = tr2.statisticsCountsSeparateSuspendedBuriedCards();
const total = tr2.statisticsCountsTotalCards();
const label = trI18n.statisticsCountsSeparateSuspendedBuriedCards();
const total = trI18n.statisticsCountsTotalCards();
</script>
<Graph title={graphData.title}>

View file

@ -4,10 +4,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import type { Stats } from "../lib/proto";
import * as tr from "../lib/i18n";
import type { PreferenceStore } from "../sveltelib/preferences";
import { createEventDispatcher } from "svelte";
import { tr } from "../lib/i18n";
import HistogramGraph from "./HistogramGraph.svelte";
import Graph from "./Graph.svelte";

View file

@ -14,6 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import TableData from "./TableData.svelte";
import type { PreferenceStore } from "../sveltelib/preferences";
import { tr } from "../lib/i18n";
import type { HistogramData } from "./histogram-graph";
import { GraphRange, RevlogRange } from "./graph-helpers";
import type { TableDatum, SearchEventMap } from "./graph-helpers";
@ -21,7 +22,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { GraphData } from "./future-due";
export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>;
const dispatch = createEventDispatcher<SearchEventMap>();

View file

@ -3,10 +3,10 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import { tr } from "../lib/i18n";
import { RevlogRange, GraphRange } from "./graph-helpers";
import { timeSpan, MONTH, YEAR } from "../lib/time";
import * as tr from "../lib/i18n";
export let revlogRange: RevlogRange;
export let graphRange: GraphRange;
export let followRevlog: boolean = false;

View file

@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import type { Stats } from "../lib/proto";
import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte";
import AxisTicks from "./AxisTicks.svelte";
@ -12,11 +10,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import GraphRangeRadios from "./GraphRangeRadios.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte";
import HoverColumns from "./HoverColumns.svelte";
import type { Stats } from "../lib/proto";
import { tr } from "../lib/i18n";
import { defaultGraphBounds, RevlogRange, GraphRange } from "./graph-helpers";
import { renderHours } from "./hours";
export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let revlogRange: RevlogRange;
let graphRange: GraphRange = GraphRange.Year;

View file

@ -3,17 +3,16 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import { timeSpan, MONTH } from "../lib/time";
import type { Stats } from "../lib/proto";
import type { PreferenceStore } from "../sveltelib/preferences";
import { createEventDispatcher } from "svelte";
import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte";
import HistogramGraph from "./HistogramGraph.svelte";
import TableData from "./TableData.svelte";
import { timeSpan, MONTH } from "../lib/time";
import { tr } from "../lib/i18n";
import type { Stats } from "../lib/proto";
import type { PreferenceStore } from "../sveltelib/preferences";
import { createEventDispatcher } from "svelte";
import type { HistogramData } from "./histogram-graph";
import {
gatherIntervalData,
@ -24,7 +23,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { TableDatum, SearchEventMap } from "./graph-helpers";
export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>;
const dispatch = createEventDispatcher<SearchEventMap>();

View file

@ -4,8 +4,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import type { GraphBounds } from "./graph-helpers";
import { tr } from "../lib/i18n";
export let bounds: GraphBounds;
import * as tr from "../lib/i18n";
const noData = tr.statisticsNoData();
</script>

View file

@ -3,11 +3,10 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import type { Writable } from "svelte/store";
import InputBox from "./InputBox.svelte";
import * as tr from "../lib/i18n";
import type { Writable } from "svelte/store";
import { tr } from "../lib/i18n";
import { RevlogRange, daysToRevlogRange } from "./graph-helpers";
enum SearchRange {

View file

@ -3,8 +3,6 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="typescript">
import type { Stats } from "../lib/proto";
import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte";
import NoDataOverlay from "./NoDataOverlay.svelte";
@ -14,6 +12,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import AxisTicks from "./AxisTicks.svelte";
import HoverColumns from "./HoverColumns.svelte";
import type { Stats } from "../lib/proto";
import { tr } from "../lib/i18n";
import { defaultGraphBounds, RevlogRange, GraphRange } from "./graph-helpers";
import type { TableDatum } from "./graph-helpers";
import { gatherData, renderReviews } from "./reviews";
@ -21,7 +21,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let sourceData: Stats.GraphsResponse | null = null;
export let revlogRange: RevlogRange;
import * as tr from "../lib/i18n";
let graphData: GraphData | null = null;

View file

@ -19,10 +19,10 @@ import {
import type { Bin } from "d3";
import type { HistogramData } from "./histogram-graph";
import { tr } from "../lib/i18n";
import { dayLabel } from "../lib/time";
import { GraphRange } from "./graph-helpers";
import type { TableDatum, SearchDispatch } from "./graph-helpers";
import * as tr from "../lib/i18n";
export interface GraphData {
daysAdded: number[];

View file

@ -6,8 +6,6 @@
@typescript-eslint/no-explicit-any: "off",
*/
import { Stats } from "../lib/proto";
import {
interpolateRdYlGn,
select,
@ -19,6 +17,8 @@ import {
axisLeft,
sum,
} from "d3";
import { Stats } from "../lib/proto";
import { tr } from "../lib/i18n";
import { showTooltip, hideTooltip } from "./tooltip";
import {
GraphBounds,
@ -26,7 +26,6 @@ import {
GraphRange,
millisecondCutoffForRange,
} from "./graph-helpers";
import * as tr from "../lib/i18n";
type ButtonCounts = [number, number, number, number];

View file

@ -29,8 +29,7 @@ import {
SearchDispatch,
} from "./graph-helpers";
import { clickableClass } from "./graph-styles";
import { i18n } from "../lib/i18n";
import * as tr from "../lib/i18n";
import { tr, i18n } from "../lib/i18n";
export interface GraphData {
// indexed by day, where day is relative to today

View file

@ -6,6 +6,7 @@
@typescript-eslint/no-explicit-any: "off",
*/
import { tr } from "../lib/i18n";
import { CardQueue, CardType } from "../lib/cards";
import type { Stats, Cards } from "../lib/proto";
import {
@ -22,8 +23,6 @@ import {
} from "d3";
import type { GraphBounds } from "./graph-helpers";
import * as tr from "../lib/i18n";
type Count = [string, number, boolean, string];
export interface GraphData {
title: string;

View file

@ -16,11 +16,10 @@ import {
interpolateRdYlGn,
} from "d3";
import type { Bin, ScaleLinear } from "d3";
import { tr } from "../lib/i18n";
import { CardType } from "../lib/cards";
import type { HistogramData } from "./histogram-graph";
import type { TableDatum, SearchDispatch } from "./graph-helpers";
import * as tr from "../lib/i18n";
export interface GraphData {
eases: number[];

View file

@ -17,13 +17,13 @@ import {
interpolateGreens,
} from "d3";
import type { Bin } from "d3";
import { tr } from "../lib/i18n";
import { CardQueue } from "../lib/cards";
import type { HistogramData } from "./histogram-graph";
import { dayLabel } from "../lib/time";
import { GraphRange } from "./graph-helpers";
import type { TableDatum, SearchDispatch } from "./graph-helpers";
import * as tr from "../lib/i18n";
export interface GraphData {
dueCounts: Map<number, number>;

View file

@ -21,6 +21,7 @@ import {
curveBasis,
} from "d3";
import { tr } from "../lib/i18n";
import { showTooltip, hideTooltip } from "./tooltip";
import {
GraphBounds,
@ -29,7 +30,6 @@ import {
millisecondCutoffForRange,
} from "./graph-helpers";
import { oddTickClass } from "./graph-styles";
import * as tr from "../lib/i18n";
interface Hour {
hour: number;

View file

@ -3,7 +3,7 @@
import type { SvelteComponent } from "svelte/internal";
import { setupI18n, ModuleName } from "../lib/i18n";
import { setupI18n, tr } from "../lib/i18n";
import { checkNightMode } from "../lib/nightmode";
import GraphsPage from "./GraphsPage.svelte";
@ -33,16 +33,18 @@ export function graphs(
): void {
const nightMode = checkNightMode();
setupI18n({ modules: [ModuleName.STATISTICS, ModuleName.SCHEDULING] }).then(() => {
new GraphsPage({
target,
props: {
graphs,
nightMode,
initialSearch: search,
initialDays: days,
controller,
},
});
});
setupI18n({ modules: [tr.ModuleName.STATISTICS, tr.ModuleName.SCHEDULING] }).then(
() => {
new GraphsPage({
target,
props: {
graphs,
nightMode,
initialSearch: search,
initialDays: days,
controller,
},
});
}
);
}

View file

@ -18,12 +18,12 @@ import {
interpolateBlues,
} from "d3";
import type { Bin } from "d3";
import { tr } from "../lib/i18n";
import { timeSpan } from "../lib/time";
import { CardType } from "../lib/cards";
import type { HistogramData } from "./histogram-graph";
import type { TableDatum, SearchDispatch } from "./graph-helpers";
import { timeSpan } from "../lib/time";
import * as tr from "../lib/i18n";
export interface IntervalGraphData {
intervals: number[];

View file

@ -32,10 +32,10 @@ import {
} from "d3";
import type { Bin } from "d3";
import { tr } from "../lib/i18n";
import type { TableDatum } from "./graph-helpers";
import { GraphBounds, setDataAvailable, GraphRange } from "./graph-helpers";
import { showTooltip, hideTooltip } from "./tooltip";
import * as tr from "../lib/i18n";
interface Reviews {
learn: number;

View file

@ -3,8 +3,7 @@
import { Stats } from "../lib/proto";
import { studiedToday } from "../lib/time";
import * as tr from "../lib/i18n";
import { tr } from "../lib/i18n";
export interface TodayData {
title: string;

View file

@ -25,7 +25,7 @@ py_binary(
genrule(
name = "fluent_gen",
outs = ["i18n.ts"],
outs = ["i18n-generated.ts"],
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $@",
tools = [
"genfluent",
@ -36,7 +36,7 @@ genrule(
typescript(
name = "lib",
generated = [
":i18n.ts",
":i18n-generated.ts",
],
deps = [
":backend_proto",

View file

@ -18,8 +18,7 @@ class Variable(TypedDict):
def methods() -> str:
out = [
'import { i18n } from "./i18n_helpers";',
'export { i18n, setupI18n } from "./i18n_helpers";',
'import { i18n } from "./i18n";',
]
for module in modules:
for translation in module["translations"]:

View file

@ -79,7 +79,7 @@ export class I18n {
// global singleton
export const i18n = new I18n();
import type { ModuleName } from "./i18n";
import type { ModuleName } from "./i18n-generated";
export async function setupI18n(args: { modules: ModuleName[] }): Promise<void> {
const resp = await fetch("/_anki/i18nResources", {
@ -102,3 +102,5 @@ export async function setupI18n(args: { modules: ModuleName[] }): Promise<void>
}
i18n.langs = json.langs;
}
export * as tr from "./i18n-generated";

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import * as tr from "./i18n";
import { tr } from "./i18n";
import { isApplePlatform } from "./platform";
// those are the modifiers that Anki works with

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import * as tr from "./i18n";
import { tr } from "./i18n";
export const SECOND = 1.0;
export const MINUTE = 60.0 * SECOND;

View file

@ -1,6 +1,7 @@
{
"extends": "../tsconfig.json",
"include": ["*", "../../bazel-bin/ts/lib"],
"include": ["*"],
"rootDirs": ["../../bazel-bin/ts/lib"],
"references": [],
"compilerOptions": {
"types": ["jest"]