From a3adc2526fcb06c6b6a40492e4ff239f38d17288 Mon Sep 17 00:00:00 2001 From: Benjamin Singleton <19498453+tetrogem@users.noreply.github.com> Date: Sat, 14 Feb 2026 22:56:17 -0600 Subject: [PATCH] wip: RichText & Templating for i18n, refactored & began i18n for Discord Server Rules using the new features --- apps/vdn-static/eslint.config.js | 8 +- apps/vdn-static/src/App.vue | 10 +- .../src/components/atoms/DropdownItem.vue | 14 + .../src/components/atoms/I18nTemplate.vue | 45 ++ .../src/components/atoms/OptionalParent.vue | 12 + .../src/components/atoms/RichTemplate.vue | 27 ++ .../components/atoms/RichTemplateParts.vue | 85 ++++ .../src/components/atoms/RichText.vue | 31 ++ .../src/components/atoms/SmartLink.ts | 7 + .../{organisms => atoms}/SmartLink.vue | 8 +- .../molecules/DiscordRuleOverview.vue | 33 ++ .../molecules/LearningResourceWrapper.vue | 3 +- .../src/components/organisms/LocalePicker.vue | 19 +- apps/vdn-static/src/i18n/index.ts | 411 +++++++++++++++++- apps/vdn-static/src/i18n/locale.ts | 29 +- apps/vdn-static/src/i18n/marker.ts | 39 ++ apps/vdn-static/src/i18n/rich.ts | 81 ++++ apps/vdn-static/src/locales/en_US.ts | 76 +++- apps/vdn-static/src/locales/wp_VL.ts | 3 +- apps/vdn-static/src/main.ts | 3 +- apps/vdn-static/src/pages/discord/rules.vue | 96 ++-- apps/vdn-static/src/pages/index.vue | 9 +- apps/vdn-static/src/pages/kotoba.vue | 8 +- apps/vdn-static/src/pages/resources.vue | 8 +- apps/vdn-static/tsconfig.app.json | 5 + 25 files changed, 929 insertions(+), 141 deletions(-) create mode 100644 apps/vdn-static/src/components/atoms/DropdownItem.vue create mode 100644 apps/vdn-static/src/components/atoms/I18nTemplate.vue create mode 100644 apps/vdn-static/src/components/atoms/OptionalParent.vue create mode 100644 apps/vdn-static/src/components/atoms/RichTemplate.vue create mode 100644 apps/vdn-static/src/components/atoms/RichTemplateParts.vue create mode 100644 apps/vdn-static/src/components/atoms/RichText.vue create mode 100644 apps/vdn-static/src/components/atoms/SmartLink.ts rename apps/vdn-static/src/components/{organisms => atoms}/SmartLink.vue (89%) create mode 100644 apps/vdn-static/src/components/molecules/DiscordRuleOverview.vue create mode 100644 apps/vdn-static/src/i18n/marker.ts create mode 100644 apps/vdn-static/src/i18n/rich.ts diff --git a/apps/vdn-static/eslint.config.js b/apps/vdn-static/eslint.config.js index 166fff0..506d761 100644 --- a/apps/vdn-static/eslint.config.js +++ b/apps/vdn-static/eslint.config.js @@ -32,7 +32,13 @@ export default defineConfig([ "error", { element: ["a", "RouterLink"], - message: "Use instead", + message: "Use instead.", + }, + { element: ["i18n-t"], message: "Use instead." }, + { + element: ["RichTemplateParts"], + message: + "Do not use the internal component. Use instead.", }, ], // allow interfaces to only extend another interface without adding properties diff --git a/apps/vdn-static/src/App.vue b/apps/vdn-static/src/App.vue index 6b6ae2d..012c225 100644 --- a/apps/vdn-static/src/App.vue +++ b/apps/vdn-static/src/App.vue @@ -3,11 +3,13 @@ import "./assets/style.scss"; import { computed, ref, type Ref } from "vue"; import LocalePicker from "./components/organisms/LocalePicker.vue"; import { vOnClickOutside } from "@vueuse/components"; -import { useLocale } from "./i18n"; import { useRouter } from "vue-router"; -import SmartLink from "./components/organisms/SmartLink.vue"; +import SmartLink from "./components/atoms/SmartLink.vue"; import type { SmartDest } from "./utils/smart-dest"; import type { Locale } from "./i18n/locale"; +import { useI18n } from "./i18n"; + +const i18n = useI18n(); const burgerOpen: Ref = ref(false); @@ -19,8 +21,6 @@ const closeBurger = (): void => { burgerOpen.value = false; }; -const locale = useLocale(); - const router = useRouter(); router.beforeEach(() => { closeBurger(); @@ -39,7 +39,7 @@ const NAVBAR_ITEM_ORDER = [ const navbarItems = computed(() => NAVBAR_ITEM_ORDER.map((id): NavbarItem => { - const label = locale.value.navbar[id]; + const label = i18n.t(`navbar.${id}`); const to = ((): SmartDest => { switch (id) { diff --git a/apps/vdn-static/src/components/atoms/DropdownItem.vue b/apps/vdn-static/src/components/atoms/DropdownItem.vue new file mode 100644 index 0000000..8310122 --- /dev/null +++ b/apps/vdn-static/src/components/atoms/DropdownItem.vue @@ -0,0 +1,14 @@ + + + diff --git a/apps/vdn-static/src/components/atoms/I18nTemplate.vue b/apps/vdn-static/src/components/atoms/I18nTemplate.vue new file mode 100644 index 0000000..5e6c689 --- /dev/null +++ b/apps/vdn-static/src/components/atoms/I18nTemplate.vue @@ -0,0 +1,45 @@ + + + diff --git a/apps/vdn-static/src/components/atoms/OptionalParent.vue b/apps/vdn-static/src/components/atoms/OptionalParent.vue new file mode 100644 index 0000000..4454b82 --- /dev/null +++ b/apps/vdn-static/src/components/atoms/OptionalParent.vue @@ -0,0 +1,12 @@ + + + diff --git a/apps/vdn-static/src/components/atoms/RichTemplate.vue b/apps/vdn-static/src/components/atoms/RichTemplate.vue new file mode 100644 index 0000000..6fd5315 --- /dev/null +++ b/apps/vdn-static/src/components/atoms/RichTemplate.vue @@ -0,0 +1,27 @@ + + + diff --git a/apps/vdn-static/src/components/atoms/RichTemplateParts.vue b/apps/vdn-static/src/components/atoms/RichTemplateParts.vue new file mode 100644 index 0000000..22a1fe6 --- /dev/null +++ b/apps/vdn-static/src/components/atoms/RichTemplateParts.vue @@ -0,0 +1,85 @@ + + + diff --git a/apps/vdn-static/src/components/atoms/RichText.vue b/apps/vdn-static/src/components/atoms/RichText.vue new file mode 100644 index 0000000..f7ac465 --- /dev/null +++ b/apps/vdn-static/src/components/atoms/RichText.vue @@ -0,0 +1,31 @@ + + + diff --git a/apps/vdn-static/src/components/atoms/SmartLink.ts b/apps/vdn-static/src/components/atoms/SmartLink.ts new file mode 100644 index 0000000..205334e --- /dev/null +++ b/apps/vdn-static/src/components/atoms/SmartLink.ts @@ -0,0 +1,7 @@ +import type { SmartDest } from "@/utils/smart-dest"; + +export interface SmartLinkProps { + to: SmartDest; + newTab?: boolean; + covert?: boolean; +} diff --git a/apps/vdn-static/src/components/organisms/SmartLink.vue b/apps/vdn-static/src/components/atoms/SmartLink.vue similarity index 89% rename from apps/vdn-static/src/components/organisms/SmartLink.vue rename to apps/vdn-static/src/components/atoms/SmartLink.vue index ea7933f..9552713 100644 --- a/apps/vdn-static/src/components/organisms/SmartLink.vue +++ b/apps/vdn-static/src/components/atoms/SmartLink.vue @@ -1,13 +1,7 @@ + + diff --git a/apps/vdn-static/src/components/molecules/LearningResourceWrapper.vue b/apps/vdn-static/src/components/molecules/LearningResourceWrapper.vue index 4535d34..35dd759 100644 --- a/apps/vdn-static/src/components/molecules/LearningResourceWrapper.vue +++ b/apps/vdn-static/src/components/molecules/LearningResourceWrapper.vue @@ -1,6 +1,7 @@