aboutsummaryrefslogtreecommitdiff
path: root/src/lib/CommandPalette/actions.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-05-24 13:22:34 +0000
committerFuwn <[email protected]>2026-05-24 13:22:34 +0000
commit56a7a7851b09cb30a5cd543c8cb4f926109b4290 (patch)
treea620f908405fa48fd601580c5a48432831ec5c33 /src/lib/CommandPalette/actions.ts
parentfix(layout): preserve list panel when clicking action buttons in summary (diff)
downloaddue.moe-56a7a7851b09cb30a5cd543c8cb4f926109b4290.tar.xz
due.moe-56a7a7851b09cb30a5cd543c8cb4f926109b4290.zip
refactor(locale): move hardcoded UI strings into english locale
Adds optional namespaces (common, errors, commandPalette, headTitle, notifications, schedule, events, home, reader, routes, badgePreview, badgeWall) and extends existing ones (settings.*, lists.*, tools.*, user.*, hololive.*) on the Locale interface. New fields are optional so japanese.ts can omit them; svelte-i18n's fallbackLocale handles the runtime miss. HeadTitle gains an optional routeKey prop for type-safe lookup. defaultActions becomes a factory so the command palette re-reads locale on language toggle. The existing JP feedback translation in routes/settings is preserved via japanese.ts. Out of scope (kept hardcoded): service-worker.ts, app.html, Landing*.svelte, tools.ts registry, Easter Event 2025 pages.
Diffstat (limited to 'src/lib/CommandPalette/actions.ts')
-rw-r--r--src/lib/CommandPalette/actions.ts356
1 files changed, 181 insertions, 175 deletions
diff --git a/src/lib/CommandPalette/actions.ts b/src/lib/CommandPalette/actions.ts
index 9915fe66..d2ed5a1d 100644
--- a/src/lib/CommandPalette/actions.ts
+++ b/src/lib/CommandPalette/actions.ts
@@ -1,4 +1,6 @@
import { invalidateListCaches } from "$lib/Media/invalidate";
+import locale from "$stores/locale";
+import { get } from "svelte/store";
export interface CommandPaletteAction {
name: string;
@@ -9,178 +11,182 @@ export interface CommandPaletteAction {
actions?: CommandPaletteAction[];
}
-export const defaultActions: CommandPaletteAction[] = [
- {
- name: "Home",
- url: "/",
- tags: [
- "main",
- "manga",
- "anime",
- "light",
- "dashboard",
- "start",
- "begin",
- "novels",
- "list",
- ],
- actions: [
- {
- name: "Upcoming Episodes",
- url: "/",
- tags: ["anime", "list"],
- },
- {
- name: "Not Yet Released",
- url: "/",
- tags: ["anime", "schedule", "list"],
- },
- {
- name: "Due Episodes",
- url: "/",
- tags: ["anime", "list"],
- },
- {
- name: "Manga & Light Novels",
- url: "/",
- tags: ["novels", "manga", "list"],
- },
- ],
- },
- {
- name: "Completed",
- url: "/completed",
- tags: [
- "finish",
- "end",
- "done",
- "finish",
- "end",
- "done",
- "anime",
- "novels",
- "manga",
- ],
- actions: [
- {
- name: "Anime",
- url: "/completed",
- tags: ["anime", "list"],
- },
- {
- name: "Manga & Light Novels",
- url: "/completed",
- tags: ["novels", "manga", "list"],
- },
- ],
- },
- {
- name: "Subtitle Schedule",
- url: "/schedule",
- tags: ["anime", "subs"],
- },
- {
- name: "hololive Schedule",
- url: "/hololive",
- tags: ["vtuber", "youtube", "virtual", "twitch", "stream"],
- },
- {
- name: "Character Birthdays",
- url: "/birthdays",
- tags: ["schedule", "vtuber", "date"],
- },
- {
- name: "New Releases",
- url: "/releases",
- tags: ["novels", "manga", "date", "schedule", "time"],
- },
- {
- name: "Settings",
- url: "/settings",
- tags: [
- "sync",
- "display",
- "hide",
- "panels",
- "motion",
- "accessibility",
- "notifications",
- "rss",
- "warning",
- "show",
- "links",
- "sort",
- "calculation",
- "cache",
- "clear",
- "debug",
- "language",
- "locale",
- ],
- actions: [
- {
- name: "Settings Sync",
- url: "/settings#sync",
- tags: ["settings"],
- },
- {
- name: "RSS Feeds",
- url: "/settings#feeds",
- tags: ["settings"],
- },
- {
- name: "Display",
- url: "/settings",
- tags: ["settings"],
- },
- {
- name: "Calculation",
- url: "/settings",
- tags: ["settings"],
- },
- {
- name: "Cache",
- url: "/settings",
- tags: ["settings"],
- },
- {
- name: "Debug",
- url: "/settings#debug",
- tags: ["settings"],
- },
- ],
- },
- {
- name: "My Profile",
- url: "/user",
- tags: ["user", "me", "settings"],
- actions: [
- {
- name: "User Preferences",
- url: "/user",
- tags: ["user", "me", "settings"],
- },
- ],
- },
- {
- name: "My Badge Wall",
- url: "/user?badges=1",
- tags: ["user", "me", "settings"],
- },
- {
- name: "Refresh Anime & Manga List Caches",
- url: "",
- preventDefault: true,
- tags: [
- "cache",
- "clear",
- "refresh",
- "invalidate",
- "debug",
- "anime",
- "manga",
- "list",
- ],
- onClick: invalidateListCaches,
- },
-];
+export const defaultActions = (): CommandPaletteAction[] => {
+ const l = get(locale)();
+
+ return [
+ {
+ name: l.navigation.home,
+ url: "/",
+ tags: [
+ "main",
+ "manga",
+ "anime",
+ "light",
+ "dashboard",
+ "start",
+ "begin",
+ "novels",
+ "list",
+ ],
+ actions: [
+ {
+ name: l.lists.upcoming.episodes.title,
+ url: "/",
+ tags: ["anime", "list"],
+ },
+ {
+ name: l.lists.upcoming.notYetReleased.title,
+ url: "/",
+ tags: ["anime", "schedule", "list"],
+ },
+ {
+ name: l.lists.due.episodes.title,
+ url: "/",
+ tags: ["anime", "list"],
+ },
+ {
+ name: l.lists.due.mangaAndLightNovels.title,
+ url: "/",
+ tags: ["novels", "manga", "list"],
+ },
+ ],
+ },
+ {
+ name: l.navigation.completed,
+ url: "/completed",
+ tags: [
+ "finish",
+ "end",
+ "done",
+ "finish",
+ "end",
+ "done",
+ "anime",
+ "novels",
+ "manga",
+ ],
+ actions: [
+ {
+ name: l.settings.media.anime,
+ url: "/completed",
+ tags: ["anime", "list"],
+ },
+ {
+ name: l.lists.completed.mangaAndLightNovels.title,
+ url: "/completed",
+ tags: ["novels", "manga", "list"],
+ },
+ ],
+ },
+ {
+ name: l.navigation.subtitleSchedule,
+ url: "/schedule",
+ tags: ["anime", "subs"],
+ },
+ {
+ name: l.navigation.hololive,
+ url: "/hololive",
+ tags: ["vtuber", "youtube", "virtual", "twitch", "stream"],
+ },
+ {
+ name: l.tools.tool.characterBirthdays.short,
+ url: "/birthdays",
+ tags: ["schedule", "vtuber", "date"],
+ },
+ {
+ name: l.navigation.newReleases,
+ url: "/releases",
+ tags: ["novels", "manga", "date", "schedule", "time"],
+ },
+ {
+ name: l.navigation.settings,
+ url: "/settings",
+ tags: [
+ "sync",
+ "display",
+ "hide",
+ "panels",
+ "motion",
+ "accessibility",
+ "notifications",
+ "rss",
+ "warning",
+ "show",
+ "links",
+ "sort",
+ "calculation",
+ "cache",
+ "clear",
+ "debug",
+ "language",
+ "locale",
+ ],
+ actions: [
+ {
+ name: l.settings.settingsSync.title,
+ url: "/settings#sync",
+ tags: ["settings"],
+ },
+ {
+ name: l.settings.rssFeeds.title,
+ url: "/settings#feeds",
+ tags: ["settings"],
+ },
+ {
+ name: l.settings.display.title,
+ url: "/settings",
+ tags: ["settings"],
+ },
+ {
+ name: l.settings.calculation.title,
+ url: "/settings",
+ tags: ["settings"],
+ },
+ {
+ name: l.settings.cache.title,
+ url: "/settings",
+ tags: ["settings"],
+ },
+ {
+ name: l.settings.debug.title,
+ url: "/settings#debug",
+ tags: ["settings"],
+ },
+ ],
+ },
+ {
+ name: l.navigation.myProfile,
+ url: "/user",
+ tags: ["user", "me", "settings"],
+ actions: [
+ {
+ name: l.user.preferences.title,
+ url: "/user",
+ tags: ["user", "me", "settings"],
+ },
+ ],
+ },
+ {
+ name: l.navigation.myBadgeWall,
+ url: "/user?badges=1",
+ tags: ["user", "me", "settings"],
+ },
+ {
+ name: l.commandPalette?.refreshCaches ?? "Refresh Anime & Manga List Caches",
+ url: "",
+ preventDefault: true,
+ tags: [
+ "cache",
+ "clear",
+ "refresh",
+ "invalidate",
+ "debug",
+ "anime",
+ "manga",
+ "list",
+ ],
+ onClick: invalidateListCaches,
+ },
+ ];
+};