From 8e7895ae594676a7cb8b55e38dc809523652b199 Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Fri, 30 Jan 2026 22:58:07 +0100 Subject: [PATCH] feat(i18n): i18nize everything --- app/components/Common/ConfirmationModal.vue | 4 +- .../Contact/BottomScreen/BottomScreen.vue | 31 ++++++---- app/components/Screen.vue | 6 +- .../BottomScreen/Menus/Clock/Achievements.vue | 13 ++-- .../BottomScreen/Menus/Clock/Date.vue | 10 ++-- .../BottomScreen/Menus/Clock/Time.vue | 8 +-- .../Settings/BottomScreen/Menus/Menus.vue | 8 +-- .../BottomScreen/Menus/Options/2048.vue | 16 +++-- .../BottomScreen/Menus/Options/Language.vue | 4 +- .../BottomScreen/Menus/Options/StartUp.vue | 16 ++--- .../BottomScreen/Menus/User/Birthday.vue | 10 ++-- .../BottomScreen/Menus/User/Color.vue | 4 +- .../Menus/User/PersonalMessage.vue | 4 +- .../BottomScreen/Menus/User/UserName.vue | 4 +- app/pages/gallery.vue | 23 ++++---- i18n/locales/en.json | 59 +++++++++++++++++-- 16 files changed, 142 insertions(+), 78 deletions(-) diff --git a/app/components/Common/ConfirmationModal.vue b/app/components/Common/ConfirmationModal.vue index 22ff8c9..3c254ea 100644 --- a/app/components/Common/ConfirmationModal.vue +++ b/app/components/Common/ConfirmationModal.vue @@ -53,8 +53,8 @@ onUnmounted(() => { diff --git a/app/components/Contact/BottomScreen/BottomScreen.vue b/app/components/Contact/BottomScreen/BottomScreen.vue index 1aec94a..d646498 100644 --- a/app/components/Contact/BottomScreen/BottomScreen.vue +++ b/app/components/Contact/BottomScreen/BottomScreen.vue @@ -10,13 +10,17 @@ const achievements = useAchievementsStore(); const confirmationModal = useConfirmationModal(); const ACTIONS = { - github: ["Open", "Github profile", "https://github.com/pihkaal"], - email: ["Copy", "Email", "hello@pihkaal.me"], - website: ["Copy", "Website link", "https://pihkaal.me"], - cv: ["Open", "CV", "https://pihkaal.me/cv"], + github: [ + "open", + "contact.actions.githubProfile", + "https://github.com/pihkaal", + ], + email: ["copy", "contact.actions.email", "hello@pihkaal.me"], + website: ["copy", "contact.actions.websiteLink", "https://pihkaal.me"], + cv: ["open", "contact.actions.cv", "https://pihkaal.me/cv"], } as const satisfies Record< string, - [action: "Copy" | "Open", verb: string, content: string] + [action: "copy" | "open", verbKey: string, content: string] >; const { selected, selectorPosition } = useButtonNavigation({ @@ -54,20 +58,21 @@ const { selected, selectorPosition } = useButtonNavigation({ }); const actionateButton = async (button: (typeof selected)["value"]) => { - const [action, verb, content] = ACTIONS[button]; - if (action === "Copy") { + const [action, verbKey, content] = ACTIONS[button]; + const verb = $t(verbKey); + if (action === "copy") { try { await navigator.clipboard.writeText(content); - store.pushNotification(`${verb} copied to clipboard`); + store.pushNotification($t("contact.copiedToClipboard", { item: verb })); } catch (error) { console.error("Failed to copy to clipboard:", error); } } else { const url = content.replace(/^https?:\/\//, ""); confirmationModal.open({ - text: `Open ${url}?`, + text: $t("contact.openUrl", { url }), onConfirm: async () => { - store.pushNotification(`${verb} opened`); + store.pushNotification($t("contact.opened", { item: verb })); await sleep(100); await navigateTo(content, { open: { target: "_blank " } }); @@ -94,7 +99,7 @@ const actionateButton = async (button: (typeof selected)["value"]) => { /> { ? store.outro.stage2Opacity : 1 " - b-label="Quit" - :a-label="ACTIONS[selected][0]" + :b-label="$t('common.quit')" + :a-label="$t(`contact.actions.${ACTIONS[selected][0]}`)" @activate-b="store.animateOutro()" /> diff --git a/app/components/Screen.vue b/app/components/Screen.vue index ba68fc8..2202e31 100644 --- a/app/components/Screen.vue +++ b/app/components/Screen.vue @@ -71,7 +71,11 @@ const renderFrame = (timestamp: number) => { for (const callback of sortedCallbacks) { ctx.save(); - callback(ctx, deltaTime, lastRealFrameTime); + try { + callback(ctx, deltaTime, lastRealFrameTime); + } catch (error: unknown) { + console.error(error); + } ctx.restore(); } diff --git a/app/components/Settings/BottomScreen/Menus/Clock/Achievements.vue b/app/components/Settings/BottomScreen/Menus/Clock/Achievements.vue index 60ade11..ae574d8 100644 --- a/app/components/Settings/BottomScreen/Menus/Clock/Achievements.vue +++ b/app/components/Settings/BottomScreen/Menus/Clock/Achievements.vue @@ -87,7 +87,8 @@ onRender((ctx) => { ctx.font = "10px NDS10"; ctx.textBaseline = "top"; ctx.fillStyle = "#010101"; - const { actualBoundingBoxRight: textWidth } = ctx.measureText("View All"); + const viewAllText = $t("settings.clock.achievements.viewAll"); + const { actualBoundingBoxRight: textWidth } = ctx.measureText(viewAllText); const totalWidth = achievementAssets.X.rect.width + GAP + textWidth; const left = Math.ceil( @@ -99,7 +100,7 @@ onRender((ctx) => { achievementAssets.X.draw(ctx, left, 7); fillTextHCentered( ctx, - "View All", + viewAllText, left + achievementAssets.X.rect.width + GAP, 7, textWidth, @@ -110,7 +111,7 @@ onRender((ctx) => {