mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Split up i18n-generated into i18n-{translate,modules}
This commit is contained in:
parent
7170bee37e
commit
58a4190abb
12 changed files with 54 additions and 48 deletions
|
@ -1,4 +1,5 @@
|
||||||
licenses.json
|
licenses.json
|
||||||
vendor
|
vendor
|
||||||
i18n-generated.ts
|
i18n-translate.ts
|
||||||
|
i18n-modules.ts
|
||||||
backend_proto.d.ts
|
backend_proto.d.ts
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChangeNotetypeState, getChangeNotetypeInfo, getNotetypeNames } from "./lib";
|
import { ChangeNotetypeState, getChangeNotetypeInfo, getNotetypeNames } from "./lib";
|
||||||
import { setupI18n, tr } from "../lib/i18n";
|
import { setupI18n, ModuleName } 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: [tr.ModuleName.ACTIONS, tr.ModuleName.CHANGE_NOTETYPE],
|
modules: [ModuleName.ACTIONS, ModuleName.CHANGE_NOTETYPE],
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -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, tr } from "../lib/i18n";
|
import { setupI18n, ModuleName } 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: [tr.ModuleName.SCHEDULING] });
|
await setupI18n({ modules: [ModuleName.SCHEDULING] });
|
||||||
const info = await getCongratsInfo();
|
const info = await getCongratsInfo();
|
||||||
const page = new CongratsPage({
|
const page = new CongratsPage({
|
||||||
target,
|
target,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import "../sveltelib/export-runtime";
|
import "../sveltelib/export-runtime";
|
||||||
|
|
||||||
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
|
import { getDeckOptionsInfo, DeckOptionsState } from "./lib";
|
||||||
import { setupI18n, tr } from "../lib/i18n";
|
import { setupI18n, ModuleName } 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: [
|
||||||
tr.ModuleName.SCHEDULING,
|
ModuleName.SCHEDULING,
|
||||||
tr.ModuleName.ACTIONS,
|
ModuleName.ACTIONS,
|
||||||
tr.ModuleName.DECK_CONFIG,
|
ModuleName.DECK_CONFIG,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -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, tr } from "../lib/i18n";
|
import { setupI18n, ModuleName } 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: [
|
||||||
tr.ModuleName.EDITING,
|
ModuleName.EDITING,
|
||||||
tr.ModuleName.KEYBOARD,
|
ModuleName.KEYBOARD,
|
||||||
tr.ModuleName.ACTIONS,
|
ModuleName.ACTIONS,
|
||||||
tr.ModuleName.BROWSING,
|
ModuleName.BROWSING,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import type { SvelteComponent } from "svelte/internal";
|
import type { SvelteComponent } from "svelte/internal";
|
||||||
|
|
||||||
import { setupI18n, tr } from "../lib/i18n";
|
import { setupI18n, ModuleName } from "../lib/i18n";
|
||||||
import { checkNightMode } from "../lib/nightmode";
|
import { checkNightMode } from "../lib/nightmode";
|
||||||
|
|
||||||
import GraphsPage from "./GraphsPage.svelte";
|
import GraphsPage from "./GraphsPage.svelte";
|
||||||
|
@ -33,8 +33,7 @@ export function graphs(
|
||||||
): void {
|
): void {
|
||||||
const nightMode = checkNightMode();
|
const nightMode = checkNightMode();
|
||||||
|
|
||||||
setupI18n({ modules: [tr.ModuleName.STATISTICS, tr.ModuleName.SCHEDULING] }).then(
|
setupI18n({ modules: [ModuleName.STATISTICS, ModuleName.SCHEDULING] }).then(() => {
|
||||||
() => {
|
|
||||||
new GraphsPage({
|
new GraphsPage({
|
||||||
target,
|
target,
|
||||||
props: {
|
props: {
|
||||||
|
@ -45,6 +44,5 @@ export function graphs(
|
||||||
controller,
|
controller,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,13 @@ load("@rules_python//python:defs.bzl", "py_binary")
|
||||||
load("@py_deps//:requirements.bzl", "requirement")
|
load("@py_deps//:requirements.bzl", "requirement")
|
||||||
load("//ts:jest.bzl", "jest_test")
|
load("//ts:jest.bzl", "jest_test")
|
||||||
|
|
||||||
_generated = [
|
_i18n_files = [
|
||||||
"i18n-generated.ts",
|
"i18n-translate.ts",
|
||||||
|
"i18n-modules.ts",
|
||||||
|
]
|
||||||
|
|
||||||
|
_generated = _i18n_files + [
|
||||||
|
"backend_proto.d.ts",
|
||||||
]
|
]
|
||||||
|
|
||||||
protobufjs_library(
|
protobufjs_library(
|
||||||
|
@ -29,8 +34,8 @@ py_binary(
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
name = "fluent_gen",
|
name = "fluent_gen",
|
||||||
outs = ["i18n-generated.ts"],
|
outs = _i18n_files,
|
||||||
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $@",
|
cmd = "$(location genfluent) $(location //rslib/i18n:strings.json) $(OUTS)",
|
||||||
tools = [
|
tools = [
|
||||||
"genfluent",
|
"genfluent",
|
||||||
"//rslib/i18n:strings.json",
|
"//rslib/i18n:strings.json",
|
||||||
|
|
|
@ -7,7 +7,7 @@ from typing import List, Literal, TypedDict
|
||||||
|
|
||||||
import stringcase
|
import stringcase
|
||||||
|
|
||||||
strings_json, outfile = sys.argv[1:]
|
strings_json, translate_out, modules_out = sys.argv[1:]
|
||||||
modules = json.load(open(strings_json, encoding="utf8"))
|
modules = json.load(open(strings_json, encoding="utf8"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,17 +101,17 @@ def module_names() -> str:
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
|
|
||||||
out = ""
|
def write(outfile, out) -> None:
|
||||||
|
|
||||||
out += methods()
|
|
||||||
out += module_names()
|
|
||||||
|
|
||||||
open(outfile, "wb").write(
|
open(outfile, "wb").write(
|
||||||
(
|
(
|
||||||
"""// Copyright: Ankitects Pty Ltd and contributors
|
f"""// 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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
+ out
|
+ out
|
||||||
).encode("utf8")
|
).encode("utf8")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
write(translate_out, str(methods()))
|
||||||
|
write(modules_out, str(module_names()))
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../bazel-bin/ts/lib/i18n-generated.ts
|
|
1
ts/lib/i18n-modules.ts
Symbolic link
1
ts/lib/i18n-modules.ts
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../bazel-bin/ts/lib/i18n-modules.ts
|
1
ts/lib/i18n-translate.ts
Symbolic link
1
ts/lib/i18n-translate.ts
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../bazel-bin/ts/lib/i18n-translate.ts
|
|
@ -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-generated";
|
import type { ModuleName } from "./i18n-modules";
|
||||||
|
|
||||||
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", {
|
||||||
|
@ -103,4 +103,5 @@ export async function setupI18n(args: { modules: ModuleName[] }): Promise<void>
|
||||||
i18n.langs = json.langs;
|
i18n.langs = json.langs;
|
||||||
}
|
}
|
||||||
|
|
||||||
export * as tr from "./i18n-generated";
|
export { ModuleName } from "./i18n-modules";
|
||||||
|
export * as tr from "./i18n-translate";
|
||||||
|
|
Loading…
Reference in a new issue