diff --git a/apps/vdn-static/src/components/pages/ResourcesPage.vue b/apps/vdn-static/src/components/pages/ResourcesPage.vue
index 0d4e8f9..ddcbaba 100644
--- a/apps/vdn-static/src/components/pages/ResourcesPage.vue
+++ b/apps/vdn-static/src/components/pages/ResourcesPage.vue
@@ -1,25 +1,9 @@
@@ -30,7 +14,7 @@ const resourcesWithImages = computed(() =>
;
-const i18n = createI18n<[MessageSchema], Locale>({
- legacy: false,
- locale: "en_US" satisfies Locale,
- fallbackLocale: "en_US" satisfies Locale,
- messages: locales,
-});
+export const localeId = ref("en_US");
-export default i18n;
+export function useLocale(opt: UseLocaleOptions = {}) {
+ const locale = computed(() => {
+ return fallbackProxy(
+ locales[opt.locale ?? localeId.value],
+ locales["en_US"],
+ );
+ });
+
+ return readonly(locale);
+}
+
+export interface UseLocaleOptions {
+ locale?: LocaleId;
+}
+
+function fallbackProxy(obj: any, fallback: any) {
+ return new Proxy(obj, {
+ get: (target, key) => {
+ const value = target[key];
+ const fallbackValue = fallback[key];
+ if (value === undefined) {
+ return fallbackValue;
+ }
+
+ if (value === null && fallbackValue !== null) {
+ return fallbackValue;
+ }
+
+ if (
+ value === null
+ || fallbackValue === null
+ || typeof value !== "object"
+ || typeof fallbackValue !== "object"
+ ) {
+ return value;
+ }
+
+ return fallbackProxy(value, fallbackValue);
+ },
+ set: () => {
+ throw new Error("Cannot mutate locale at runtime");
+ },
+ });
+}
diff --git a/apps/vdn-static/src/i18n/locale.ts b/apps/vdn-static/src/i18n/locale.ts
new file mode 100644
index 0000000..07484cb
--- /dev/null
+++ b/apps/vdn-static/src/i18n/locale.ts
@@ -0,0 +1,39 @@
+export interface Locale {
+ localeName: string;
+ home: Layout;
+ resources: Layout;
+}
+
+export interface Layout {
+ layout: (keyof T)[] | null;
+ data: { [K in keyof T]: T[K] | null };
+}
+
+export interface HomeSections {
+ whatIsViossa: HomeSection;
+ historyOfViossa: HomeSection;
+ community: HomeSection;
+}
+
+export interface HomeSection {
+ title: string;
+ text: string;
+ image: string | null;
+ alt: string | null;
+}
+
+export interface Resources {
+ discord: Resource;
+}
+
+export interface Resource {
+ title: string;
+ subtitle: string;
+ desc: string;
+ link: string;
+ rulesLink: string;
+ image: string;
+ alt: string;
+ joinText: string;
+ rulesText: string;
+}
diff --git a/apps/vdn-static/src/i18n/types.ts b/apps/vdn-static/src/i18n/types.ts
deleted file mode 100644
index b44745d..0000000
--- a/apps/vdn-static/src/i18n/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import en_US from "../locales/en_US";
-export interface MessageSchema extends Broaden {}
-
-type Broaden = {
- [K in keyof T]: T[K] extends object ? Broaden
- : T[K] extends string ? string
- : T[K];
-} & {};
diff --git a/apps/vdn-static/src/locales/en_US.ts b/apps/vdn-static/src/locales/en_US.ts
index aebbd8f..5a1afdb 100644
--- a/apps/vdn-static/src/locales/en_US.ts
+++ b/apps/vdn-static/src/locales/en_US.ts
@@ -1,33 +1,47 @@
+import type { Locale } from "@/i18n/locale";
+import flakkaImg from "@/assets/flakka.png";
+import discordImg from "@/assets/discord.png";
+
export default {
- sections: [
- {
- title: "What is Viossa?",
- text: "Viossa is a community-created artificial pidgin language, created to simulate the formation of natural pidgin languages. Viossa is characterized by its lack of standardization, with each speaker developing a personal idiolect. Spelling and pronunciation can vary greatly, and serve as a form of personal self-expression. Viossa is learnt and taught entirely by immersion — translation is prohibited while learning.",
- image: "flakka.png",
- alt: "Flag of the Viossa Language",
+ localeName: "English",
+ home: {
+ layout: ["whatIsViossa", "historyOfViossa", "community"],
+ data: {
+ whatIsViossa: {
+ title: "What is Viossa?",
+ text: "Viossa is a community-created artificial pidgin language, created to simulate the formation of natural pidgin languages. Viossa is characterized by its lack of standardization, with each speaker developing a personal idiolect. Spelling and pronunciation can vary greatly, and serve as a form of personal self-expression. Viossa is learnt and taught entirely by immersion — translation is prohibited while learning.",
+ image: flakkaImg,
+ alt: "Flag of the Viossa Language",
+ },
+ historyOfViossa: {
+ title: "History of Viossa",
+ text: "Viossa began as a Skype group in 2014, created by members of the r/conlangs community on Reddit, as an experiment to simulate the formation of a pidgin language. Pidgins are simplified languages resulting from contact between populations with no shared common language. Unlike most pidgins, which usually have two to three contributor languages, Viossa comes from many diverse languages. This is because people from all around the world helped to contribute to Viossa's vocabulary.",
+ image: flakkaImg,
+ alt: "Flag of the Viossa Language",
+ },
+ community: {
+ title: "Community",
+ text: "The Viossa community is rich and colourful, drawing from many global traditions due to its worldwide online membership. Since the teaching culture puts an emphasis on linguistic immersion, and discourages prescriptivism, the culture of Viossa is as diverse and varied as the language and the people who speak it. For many, their personal dialect is a key form of identity and expression. The fluid nature of Viossa and lack of defined meanings makes Viossa popular for creative purposes, such as poetry and songwriting.",
+ image: null,
+ alt: null,
+ },
},
- {
- title: "History of Viossa",
- text: "Viossa began as a Skype group in 2014, created by members of the r/conlangs community on Reddit, as an experiment to simulate the formation of a pidgin language. Pidgins are simplified languages resulting from contact between populations with no shared common language. Unlike most pidgins, which usually have two to three contributor languages, Viossa comes from many diverse languages. This is because people from all around the world helped to contribute to Viossa's vocabulary.",
- image: "flakka.png",
- alt: "Flag of the Viossa Language",
+ },
+ resources: {
+ layout: ["discord"],
+ data: {
+ discord: {
+ title: "Discord Server",
+ subtitle:
+ "This is where most of the action happens! Hop on in!",
+ desc: "Originally started in 2015 something something read the rules here, then click the link below to join!",
+ link: "https://discord.gg/g3mG2gYjZD",
+ rulesLink: "https://viossadiskordserver.github.io/rules",
+ image: discordImg,
+ alt: "Discord logo",
+ joinText: "Join",
+ rulesText: "Rules",
+ },
},
- {
- title: "Community",
- text: "The Viossa community is rich and colourful, drawing from many global traditions due to its worldwide online membership. Since the teaching culture puts an emphasis on linguistic immersion, and discourages prescriptivism, the culture of Viossa is as diverse and varied as the language and the people who speak it. For many, their personal dialect is a key form of identity and expression. The fluid nature of Viossa and lack of defined meanings makes Viossa popular for creative purposes, such as poetry and songwriting.",
- },
- ],
- resources: [
- {
- title: "Discord Server",
- subtitle: "This is where most of the action happens! Hop on in!",
- desc: "Originally started in 2015 something something read the rules here, then click the link below to join!",
- link: "https://discord.gg/g3mG2gYjZD",
- rulesLink: "https://viossadiskordserver.github.io/rules",
- image: "discord.png",
- alt: "Discord logo",
- joinText: "Join",
- rulesText: "Rules",
- },
- ],
-};
+ },
+} as const satisfies Locale;
diff --git a/apps/vdn-static/src/locales/vp_VL.ts b/apps/vdn-static/src/locales/vp_VL.ts
index 3d74f48..758a1c0 100644
--- a/apps/vdn-static/src/locales/vp_VL.ts
+++ b/apps/vdn-static/src/locales/vp_VL.ts
@@ -1,35 +1,20 @@
-import type { MessageSchema } from "@/i18n/types";
+import type { Locale } from "@/i18n/locale";
+import flakkaImg from "@/assets/flakka.png";
export default {
- sections: [
- {
- title: "Kafaen afto Viossa",
- text: "Viossa tte glossa mahena grun vi nai vil fshtojena na bakadjin, grun vi svinnur ja! De aldjin zovti lera ne",
- image: "flakka.png",
- alt: "Flag of the Viossa Language",
+ localeName: "Viossa",
+ home: {
+ layout: null,
+ data: {
+ whatIsViossa: {
+ title: "Kafaen afto Viossa",
+ text: "Viossa tte glossa mahena grun vi nai vil fshtojena na bakadjin, grun vi svinnur ja! De aldjin zovti lera ne",
+ image: flakkaImg,
+ alt: "Flag of the Viossa Language",
+ },
+ historyOfViossa: null,
+ community: null,
},
- {
- title: "History of Viossa",
- text: "Viossa began as a Skype group in 2014, created by members of the r/conlangs community on Reddit, as an experiment to simulate the formation of a pidgin language. Pidgins are simplified languages resulting from contact between populations with no shared common language. Unlike most pidgins, which usually have two to three contributor languages, Viossa comes from many diverse languages. This is because people from all around the world helped to contribute to Viossa's vocabulary.",
- image: "flakka.png",
- alt: "Flag of the Viossa Language",
- },
- {
- title: "Community",
- text: "The Viossa community is rich and colourful, drawing from many global traditions due to its worldwide online membership. Since the teaching culture puts an emphasis on linguistic immersion, and discourages prescriptivism, the culture of Viossa is as diverse and varied as the language and the people who speak it. For many, their personal dialect is a key form of identity and expression. The fluid nature of Viossa and lack of defined meanings makes Viossa popular for creative purposes, such as poetry and songwriting.",
- },
- ],
- resources: [
- {
- title: "Discord Server",
- subtitle: "This is where most of the action happens! Hop on in!",
- desc: "Originally started in 2015 something something read the rules here, then click the link below to join!",
- link: "https://discord.gg/g3mG2gYjZD",
- rulesLink: "https://viossadiskordserver.github.io/rules",
- image: "discord.png",
- alt: "Discord logo",
- joinText: "Join",
- rulesText: "Rules",
- },
- ],
-} as const satisfies MessageSchema;
+ },
+ resources: { layout: null, data: { discord: null } },
+} as const satisfies Locale;
diff --git a/apps/vdn-static/src/main.ts b/apps/vdn-static/src/main.ts
index b032147..66cde5b 100644
--- a/apps/vdn-static/src/main.ts
+++ b/apps/vdn-static/src/main.ts
@@ -1,6 +1,5 @@
import { createApp } from "vue";
import App from "./App.vue";
import router from "./routes";
-import i18n from "./i18n";
-createApp(App).use(i18n).use(router).mount("#app");
+createApp(App).use(router).mount("#app");
diff --git a/apps/vdn-static/src/utils/localizeLayout.ts b/apps/vdn-static/src/utils/localizeLayout.ts
new file mode 100644
index 0000000..3145cda
--- /dev/null
+++ b/apps/vdn-static/src/utils/localizeLayout.ts
@@ -0,0 +1,16 @@
+import type { Layout } from "@/i18n/locale";
+import type { DeepReadonly } from "vue";
+
+export function localizeLayout(
+ layout: DeepReadonly>,
+): T[keyof T][] {
+ const sections: T[keyof T][] = [];
+ for (const sectionId of layout.layout ?? []) {
+ const section = (layout.data as T)[sectionId as keyof T];
+ if (section) {
+ sections.push(section);
+ }
+ }
+
+ return sections;
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d85e9a6..d122c89 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -36,6 +36,12 @@ importers:
'@types/node':
specifier: ^22.15.17
version: 22.15.31
+ '@vueuse/components':
+ specifier: ^13.3.0
+ version: 13.3.0(vue@3.5.16(typescript@5.8.3))
+ '@vueuse/core':
+ specifier: ^13.3.0
+ version: 13.3.0(vue@3.5.16(typescript@5.8.3))
bulma:
specifier: ^1.0.4
version: 1.0.4
@@ -693,6 +699,9 @@ packages:
'@types/serve-static@1.15.8':
resolution: {integrity: sha512-roei0UY3LhpOJvjbIP6ZZFngyLKl5dskOtDhxY5THRSpO+ZI+nzJ+m5yUMzGrp89YRa7lvknKkMYjqQFGwA7Sg==}
+ '@types/web-bluetooth@0.0.21':
+ resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==}
+
'@typescript-eslint/eslint-plugin@8.34.0':
resolution: {integrity: sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -831,6 +840,24 @@ packages:
vue:
optional: true
+ '@vueuse/components@13.3.0':
+ resolution: {integrity: sha512-ZnJiVknPtlWyeE4qwIXkDOlHM3W4bgMCxgeXj1Dec/aF/+8N+yAj+7rRdRUWUnqr8uKRin368RjG1FPKsF2erA==}
+ peerDependencies:
+ vue: ^3.5.0
+
+ '@vueuse/core@13.3.0':
+ resolution: {integrity: sha512-uYRz5oEfebHCoRhK4moXFM3NSCd5vu2XMLOq/Riz5FdqZMy2RvBtazdtL3gEcmDyqkztDe9ZP/zymObMIbiYSg==}
+ peerDependencies:
+ vue: ^3.5.0
+
+ '@vueuse/metadata@13.3.0':
+ resolution: {integrity: sha512-42IzJIOYCKIb0Yjv1JfaKpx8JlCiTmtCWrPxt7Ja6Wzoq0h79+YVXmBV03N966KEmDEESTbp5R/qO3AB5BDnGw==}
+
+ '@vueuse/shared@13.3.0':
+ resolution: {integrity: sha512-L1QKsF0Eg9tiZSFXTgodYnu0Rsa2P0En2LuLrIs/jgrkyiDuJSsPZK+tx+wU0mMsYHUYEjNsuE41uqqkuR8VhA==}
+ peerDependencies:
+ vue: ^3.5.0
+
accepts@2.0.0:
resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==}
engines: {node: '>= 0.6'}
@@ -2423,6 +2450,8 @@ snapshots:
'@types/node': 22.15.31
'@types/send': 0.17.5
+ '@types/web-bluetooth@0.0.21': {}
+
'@typescript-eslint/eslint-plugin@8.34.0(@typescript-eslint/parser@8.34.0(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.28.0(jiti@2.4.2))(typescript@5.8.3)':
dependencies:
'@eslint-community/regexpp': 4.12.1
@@ -2622,6 +2651,25 @@ snapshots:
typescript: 5.8.3
vue: 3.5.16(typescript@5.8.3)
+ '@vueuse/components@13.3.0(vue@3.5.16(typescript@5.8.3))':
+ dependencies:
+ '@vueuse/core': 13.3.0(vue@3.5.16(typescript@5.8.3))
+ '@vueuse/shared': 13.3.0(vue@3.5.16(typescript@5.8.3))
+ vue: 3.5.16(typescript@5.8.3)
+
+ '@vueuse/core@13.3.0(vue@3.5.16(typescript@5.8.3))':
+ dependencies:
+ '@types/web-bluetooth': 0.0.21
+ '@vueuse/metadata': 13.3.0
+ '@vueuse/shared': 13.3.0(vue@3.5.16(typescript@5.8.3))
+ vue: 3.5.16(typescript@5.8.3)
+
+ '@vueuse/metadata@13.3.0': {}
+
+ '@vueuse/shared@13.3.0(vue@3.5.16(typescript@5.8.3))':
+ dependencies:
+ vue: 3.5.16(typescript@5.8.3)
+
accepts@2.0.0:
dependencies:
mime-types: 3.0.1