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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import NotetypeSelector from "./NotetypeSelector.svelte"; import NotetypeSelector from "./NotetypeSelector.svelte";
import Mapper from "./Mapper.svelte"; import Mapper from "./Mapper.svelte";
import { ChangeNotetypeState, MapContext } from "./lib"; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n";
import MapperRow from "./MapperRow.svelte"; import MapperRow from "./MapperRow.svelte";
import { tr } from "../lib/i18n";
import { ChangeNotetypeState, MapContext } from "./lib"; import { ChangeNotetypeState, MapContext } from "./lib";
import { slide } from "svelte/transition"; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import type { ChangeNotetypeState } from "./lib"; import type { ChangeNotetypeState } from "./lib";
import { withButton } from "../components/helpers"; import { withButton } from "../components/helpers";

View file

@ -6,7 +6,7 @@
*/ */
import { ChangeNotetypeState, getChangeNotetypeInfo, getNotetypeNames } from "./lib"; import { ChangeNotetypeState, getChangeNotetypeInfo, getNotetypeNames } from "./lib";
import { setupI18n, ModuleName } from "../lib/i18n"; import { setupI18n, tr } from "../lib/i18n";
import { checkNightMode } from "../lib/nightmode"; import { checkNightMode } from "../lib/nightmode";
import ChangeNotetypePage from "./ChangeNotetypePage.svelte"; import ChangeNotetypePage from "./ChangeNotetypePage.svelte";
import { nightModeKey } from "../components/context-keys"; import { nightModeKey } from "../components/context-keys";
@ -20,7 +20,7 @@ export async function changeNotetypePage(
getChangeNotetypeInfo(oldNotetypeId, newNotetypeId), getChangeNotetypeInfo(oldNotetypeId, newNotetypeId),
getNotetypeNames(), getNotetypeNames(),
setupI18n({ 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 type { Scheduler } from "../lib/proto";
import { buildNextLearnMsg } from "./lib"; import { buildNextLearnMsg } from "./lib";
import { bridgeLink } from "../lib/bridgecommand"; import { bridgeLink } from "../lib/bridgecommand";
import { tr } from "../lib/i18n";
export let info: Scheduler.CongratsInfoResponse; export let info: Scheduler.CongratsInfoResponse;
import * as tr from "../lib/i18n";
const congrats = tr.schedulingCongratulationsFinished(); const congrats = tr.schedulingCongratulationsFinished();
let nextLearnMsg: string; let nextLearnMsg: string;

View file

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

View file

@ -4,8 +4,7 @@
import { Scheduler } from "../lib/proto"; import { Scheduler } from "../lib/proto";
import { postRequest } from "../lib/postrequest"; import { postRequest } from "../lib/postrequest";
import { naturalUnit, unitAmount, unitName } from "../lib/time"; import { naturalUnit, unitAmount, unitName } from "../lib/time";
import { tr } from "../lib/i18n";
import * as tr from "../lib/i18n";
export async function getCongratsInfo(): Promise<Scheduler.CongratsInfoResponse> { export async function getCongratsInfo(): Promise<Scheduler.CongratsInfoResponse> {
return Scheduler.CongratsInfoResponse.decode( 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import SpinBoxRow from "./SpinBoxRow.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import SwitchRow from "./SwitchRow.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import SwitchRow from "./SwitchRow.svelte"; import SwitchRow from "./SwitchRow.svelte";
import { tr } from "../lib/i18n";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import TooltipLabel from "./TooltipLabel.svelte"; import TooltipLabel from "./TooltipLabel.svelte";
import RevertButton from "./RevertButton.svelte"; import RevertButton from "./RevertButton.svelte";
import Row from "./Row.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import { getContext } from "svelte"; import { getContext } from "svelte";
import { modalsKey } from "../components/context-keys"; import { modalsKey } from "../components/context-keys";
import type { DeckOptionsState, ConfigListEntry } from "./lib"; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import SpinBoxRow from "./SpinBoxRow.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import EnumSelectorRow from "./EnumSelectorRow.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import StepsInputRow from "./StepsInputRow.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import StepsInputRow from "./StepsInputRow.svelte"; import StepsInputRow from "./StepsInputRow.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import EnumSelectorRow from "./EnumSelectorRow.svelte"; import EnumSelectorRow from "./EnumSelectorRow.svelte";
import Warning from "./Warning.svelte"; import Warning from "./Warning.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import { tr } from "../lib/i18n";
export let state: DeckOptionsState; export let state: DeckOptionsState;
export let api = {}; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import type Dropdown from "bootstrap/js/dist/dropdown"; import type Dropdown from "bootstrap/js/dist/dropdown";
import WithDropdown from "../components/WithDropdown.svelte"; import WithDropdown from "../components/WithDropdown.svelte";
import DropdownMenu from "../components/DropdownMenu.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import type Dropdown from "bootstrap/js/dist/dropdown"; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import * as tr from "../lib/i18n";
import TitledContainer from "./TitledContainer.svelte"; import TitledContainer from "./TitledContainer.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import SwitchRow from "./SwitchRow.svelte"; import SwitchRow from "./SwitchRow.svelte";
import { tr } from "../lib/i18n";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
export let state: DeckOptionsState; export let state: DeckOptionsState;

View file

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

View file

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

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // 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[] => [ export const reviewMixChoices = (): string[] => [
tr.deckConfigReviewMixMixWithReviews(), 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n";
import IconButton from "../components/IconButton.svelte"; import IconButton from "../components/IconButton.svelte";
import WithShortcut from "../components/WithShortcut.svelte"; import WithShortcut from "../components/WithShortcut.svelte";
import OnlyEditable from "./OnlyEditable.svelte"; import OnlyEditable from "./OnlyEditable.svelte";
import { tr } from "../lib/i18n";
import { withButton } from "../components/helpers"; import { withButton } from "../components/helpers";
import { ellipseIcon } from "./icons"; import { ellipseIcon } from "./icons";
import { forEditorField } from "."; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte"; import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte"; import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import IconButton from "../components/IconButton.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 WithColorHelper from "./WithColorHelper.svelte";
import OnlyEditable from "./OnlyEditable.svelte"; import OnlyEditable from "./OnlyEditable.svelte";
import { tr } from "../lib/i18n";
import { bridgeCommand } from "../lib/bridgecommand"; import { bridgeCommand } from "../lib/bridgecommand";
import { withButton } from "../components/helpers"; import { withButton } from "../components/helpers";
import { textColorIcon, highlightColorIcon, arrowIcon } from "./icons"; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte"; import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte"; import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import IconButton from "../components/IconButton.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 OnlyEditable from "./OnlyEditable.svelte";
import CommandIconButton from "./CommandIconButton.svelte"; import CommandIconButton from "./CommandIconButton.svelte";
import { tr } from "../lib/i18n";
import { getListItem } from "../lib/dom"; import { getListItem } from "../lib/dom";
import { getCurrentField, execCommand } from "./helpers"; import { getCurrentField, execCommand } from "./helpers";
import { 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte"; import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte"; import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import CommandIconButton from "./CommandIconButton.svelte"; import CommandIconButton from "./CommandIconButton.svelte";
import { tr } from "../lib/i18n";
import { import {
boldIcon, boldIcon,
italicIcon, 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte"; import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte"; import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n";
import ButtonGroup from "../components/ButtonGroup.svelte"; import ButtonGroup from "../components/ButtonGroup.svelte";
import ButtonGroupItem from "../components/ButtonGroupItem.svelte"; import ButtonGroupItem from "../components/ButtonGroupItem.svelte";
import IconButton from "../components/IconButton.svelte"; import IconButton from "../components/IconButton.svelte";
import { tr } from "../lib/i18n";
import { inlineIcon, blockIcon } from "./icons"; import { inlineIcon, blockIcon } from "./icons";
export let activeImage: HTMLImageElement; 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"> <script lang="typescript">
import { bridgeCommand } from "../lib/bridgecommand"; import { bridgeCommand } from "../lib/bridgecommand";
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import { withButton } from "../components/helpers"; import { withButton } from "../components/helpers";
import ButtonGroup from "../components/ButtonGroup.svelte"; 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"> <script lang="typescript">
import { bridgeCommand } from "../lib/bridgecommand"; import { bridgeCommand } from "../lib/bridgecommand";
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import { withButton } from "../components/helpers"; import { withButton } from "../components/helpers";
import WithShortcut from "../components/WithShortcut.svelte"; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import { bridgeCommand } from "../lib/bridgecommand"; import { bridgeCommand } from "../lib/bridgecommand";
import { fieldFocusedKey, inCodableKey } from "./context-keys"; 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 type TagEditor from "./TagEditor.svelte";
import { filterHTML } from "../html-filter"; import { filterHTML } from "../html-filter";
import { setupI18n, ModuleName } from "../lib/i18n"; import { setupI18n, tr } from "../lib/i18n";
import { isApplePlatform } from "../lib/platform"; import { isApplePlatform } from "../lib/platform";
import { registerShortcut } from "../lib/shortcuts"; import { registerShortcut } from "../lib/shortcuts";
import { bridgeCommand } from "../lib/bridgecommand"; import { bridgeCommand } from "../lib/bridgecommand";
@ -200,10 +200,10 @@ export function setTags(tags: string[]): void {
export const i18n = setupI18n({ export const i18n = setupI18n({
modules: [ modules: [
ModuleName.EDITING, tr.ModuleName.EDITING,
ModuleName.KEYBOARD, tr.ModuleName.KEYBOARD,
ModuleName.ACTIONS, tr.ModuleName.ACTIONS,
ModuleName.BROWSING, tr.ModuleName.BROWSING,
], ],
}); });

View file

@ -2,8 +2,7 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { EditorField } from "./editor-field"; import type { EditorField } from "./editor-field";
import * as tr from "../lib/i18n"; import { tr } from "../lib/i18n";
import { registerShortcut } from "../lib/shortcuts"; import { registerShortcut } from "../lib/shortcuts";
import { bridgeCommand } from "./lib"; import { bridgeCommand } from "./lib";
import { appendInParentheses } from "./helpers"; 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 GraphRangeRadios from "./GraphRangeRadios.svelte";
import TableData from "./TableData.svelte"; import TableData from "./TableData.svelte";
import { tr } from "../lib/i18n";
import { RevlogRange, GraphRange } from "./graph-helpers"; import { RevlogRange, GraphRange } from "./graph-helpers";
import type { TableDatum, SearchEventMap } from "./graph-helpers"; import type { TableDatum, SearchEventMap } from "./graph-helpers";
import type { HistogramData } from "./histogram-graph"; 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"; import type { GraphData } from "./added";
export let sourceData: Stats.GraphsResponse | null = null; export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>; export let preferences: PreferenceStore<Stats.GraphPreferences>;
let histogramData = null as HistogramData | null; 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"> <script lang="typescript">
import type { Stats } from "../lib/proto"; import type { Stats } from "../lib/proto";
import { tr } from "../lib/i18n";
import Graph from "./Graph.svelte"; import Graph from "./Graph.svelte";
import InputBox from "./InputBox.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"; import { defaultGraphBounds, GraphRange, RevlogRange } from "./graph-helpers";
export let sourceData: Stats.GraphsResponse | null = null; export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let revlogRange: RevlogRange; export let revlogRange: RevlogRange;
let graphRange: GraphRange = GraphRange.Year; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import { createEventDispatcher } from "svelte";
import type { Stats } from "../lib/proto"; import type { Stats } from "../lib/proto";
import type { PreferenceStore } from "../sveltelib/preferences"; import type { PreferenceStore } from "../sveltelib/preferences";
import { tr } from "../lib/i18n";
import { createEventDispatcher } from "svelte";
import Graph from "./Graph.svelte"; import Graph from "./Graph.svelte";
import InputBox from "./InputBox.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 sourceData: Stats.GraphsResponse;
export let preferences: PreferenceStore<Stats.GraphPreferences>; export let preferences: PreferenceStore<Stats.GraphPreferences>;
export let revlogRange: RevlogRange; export let revlogRange: RevlogRange;
import * as tr from "../lib/i18n";
export let nightMode: boolean; export let nightMode: boolean;
let { calendarFirstDayOfWeek } = preferences; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <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 Graph from "./Graph.svelte";
import InputBox from "./InputBox.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 { defaultGraphBounds } from "./graph-helpers";
import type { SearchEventMap } from "./graph-helpers"; import type { SearchEventMap } from "./graph-helpers";
import { gatherData, renderCards } from "./card-counts"; import { gatherData, renderCards } from "./card-counts";
import type { GraphData, TableDatum } from "./card-counts"; import type { GraphData, TableDatum } from "./card-counts";
export let sourceData: Stats.GraphsResponse; export let sourceData: Stats.GraphsResponse;
import * as tr2 from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>; export let preferences: PreferenceStore<Stats.GraphPreferences>;
let { cardCountsSeparateInactive, browserLinksSupported } = preferences; 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); tableData = renderCards(svg as any, bounds, graphData);
} }
const label = tr2.statisticsCountsSeparateSuspendedBuriedCards(); const label = trI18n.statisticsCountsSeparateSuspendedBuriedCards();
const total = tr2.statisticsCountsTotalCards(); const total = trI18n.statisticsCountsTotalCards();
</script> </script>
<Graph title={graphData.title}> <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"> <script lang="typescript">
import type { Stats } from "../lib/proto"; import type { Stats } from "../lib/proto";
import * as tr from "../lib/i18n";
import type { PreferenceStore } from "../sveltelib/preferences"; import type { PreferenceStore } from "../sveltelib/preferences";
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
import { tr } from "../lib/i18n";
import HistogramGraph from "./HistogramGraph.svelte"; import HistogramGraph from "./HistogramGraph.svelte";
import Graph from "./Graph.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 TableData from "./TableData.svelte";
import type { PreferenceStore } from "../sveltelib/preferences"; import type { PreferenceStore } from "../sveltelib/preferences";
import { tr } from "../lib/i18n";
import type { HistogramData } from "./histogram-graph"; import type { HistogramData } from "./histogram-graph";
import { GraphRange, RevlogRange } from "./graph-helpers"; import { GraphRange, RevlogRange } from "./graph-helpers";
import type { TableDatum, SearchEventMap } 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"; import type { GraphData } from "./future-due";
export let sourceData: Stats.GraphsResponse | null = null; export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>; export let preferences: PreferenceStore<Stats.GraphPreferences>;
const dispatch = createEventDispatcher<SearchEventMap>(); 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import { tr } from "../lib/i18n";
import { RevlogRange, GraphRange } from "./graph-helpers"; import { RevlogRange, GraphRange } from "./graph-helpers";
import { timeSpan, MONTH, YEAR } from "../lib/time"; import { timeSpan, MONTH, YEAR } from "../lib/time";
import * as tr from "../lib/i18n";
export let revlogRange: RevlogRange; export let revlogRange: RevlogRange;
export let graphRange: GraphRange; export let graphRange: GraphRange;
export let followRevlog: boolean = false; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import type { Stats } from "../lib/proto";
import Graph from "./Graph.svelte"; import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte"; import InputBox from "./InputBox.svelte";
import AxisTicks from "./AxisTicks.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 GraphRangeRadios from "./GraphRangeRadios.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte"; import CumulativeOverlay from "./CumulativeOverlay.svelte";
import HoverColumns from "./HoverColumns.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 { defaultGraphBounds, RevlogRange, GraphRange } from "./graph-helpers";
import { renderHours } from "./hours"; import { renderHours } from "./hours";
export let sourceData: Stats.GraphsResponse | null = null; export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let revlogRange: RevlogRange; export let revlogRange: RevlogRange;
let graphRange: GraphRange = GraphRange.Year; 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <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 Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte"; import InputBox from "./InputBox.svelte";
import HistogramGraph from "./HistogramGraph.svelte"; import HistogramGraph from "./HistogramGraph.svelte";
import TableData from "./TableData.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 type { HistogramData } from "./histogram-graph";
import { import {
gatherIntervalData, 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"; import type { TableDatum, SearchEventMap } from "./graph-helpers";
export let sourceData: Stats.GraphsResponse | null = null; export let sourceData: Stats.GraphsResponse | null = null;
import * as tr from "../lib/i18n";
export let preferences: PreferenceStore<Stats.GraphPreferences>; export let preferences: PreferenceStore<Stats.GraphPreferences>;
const dispatch = createEventDispatcher<SearchEventMap>(); 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"> <script lang="typescript">
import type { GraphBounds } from "./graph-helpers"; import type { GraphBounds } from "./graph-helpers";
import { tr } from "../lib/i18n";
export let bounds: GraphBounds; export let bounds: GraphBounds;
import * as tr from "../lib/i18n";
const noData = tr.statisticsNoData(); const noData = tr.statisticsNoData();
</script> </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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import type { Writable } from "svelte/store";
import InputBox from "./InputBox.svelte"; 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"; import { RevlogRange, daysToRevlogRange } from "./graph-helpers";
enum SearchRange { 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 License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="typescript"> <script lang="typescript">
import type { Stats } from "../lib/proto";
import Graph from "./Graph.svelte"; import Graph from "./Graph.svelte";
import InputBox from "./InputBox.svelte"; import InputBox from "./InputBox.svelte";
import NoDataOverlay from "./NoDataOverlay.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 AxisTicks from "./AxisTicks.svelte";
import HoverColumns from "./HoverColumns.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 { defaultGraphBounds, RevlogRange, GraphRange } from "./graph-helpers";
import type { TableDatum } from "./graph-helpers"; import type { TableDatum } from "./graph-helpers";
import { gatherData, renderReviews } from "./reviews"; 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 sourceData: Stats.GraphsResponse | null = null;
export let revlogRange: RevlogRange; export let revlogRange: RevlogRange;
import * as tr from "../lib/i18n";
let graphData: GraphData | null = null; let graphData: GraphData | null = null;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // 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 SECOND = 1.0;
export const MINUTE = 60.0 * SECOND; export const MINUTE = 60.0 * SECOND;

View file

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