Major overhaul to the theme and now functioning.

This commit is contained in:
david committed 2026-01-05 16:07:30 -05:00
1 parent 5823ca3c39
commit a475dfeab6
5218 files changed
+1643729 -13229

No files matched your search

@@ -0,0 +1,8 @@
import type { I18n, useI18n } from 'vue-i18n';
import type { LocaleInstance } from '../../composables/locale.js';
type VueI18nAdapterParams = {
i18n: I18n<any, {}, {}, string, false>;
useI18n: typeof useI18n;
};
export declare function createVueI18nAdapter({ i18n, useI18n }: VueI18nAdapterParams): LocaleInstance;
@@ -0,0 +1,87 @@
// Composables
import { useProxiedModel } from "../../composables/proxiedModel.js"; // Utilities
import { toRef, watch } from 'vue';
// Types
function useProvided(props, prop, provided) {
const internal = useProxiedModel(props, prop);
internal.value = props[prop] ?? provided.value;
watch(provided, v => {
if (props[prop] == null) {
internal.value = v;
}
});
return internal;
}
function inferDecimalSeparator(format) {
return format(0.1).includes(',') ? ',' : '.';
}
function createProvideFunction(data) {
return props => {
const current = useProvided(props, 'locale', data.current);
const fallback = useProvided(props, 'fallback', data.fallback);
const messages = useProvided(props, 'messages', data.messages);
const i18n = data.useI18n({
locale: current.value,
fallbackLocale: fallback.value,
messages: messages.value,
useScope: 'local',
legacy: false,
inheritLocale: false
});
watch(current, v => {
i18n.locale.value = v;
});
return {
name: 'vue-i18n',
current,
fallback,
messages,
decimalSeparator: toRef(() => props.decimalSeparator ?? inferDecimalSeparator(i18n.n)),
t: function (key) {
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
params[_key - 1] = arguments[_key];
}
return i18n.t(key, params);
},
n: i18n.n,
provide: createProvideFunction({
current,
fallback,
messages,
useI18n: data.useI18n
})
};
};
}
export function createVueI18nAdapter(_ref) {
let {
i18n,
useI18n
} = _ref;
const current = i18n.global.locale;
const fallback = i18n.global.fallbackLocale;
const messages = i18n.global.messages;
return {
name: 'vue-i18n',
current,
fallback,
messages,
decimalSeparator: toRef(() => inferDecimalSeparator(i18n.global.n)),
t: function (key) {
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
params[_key2 - 1] = arguments[_key2];
}
return i18n.global.t(key, params);
},
n: i18n.global.n,
provide: createProvideFunction({
current,
fallback,
messages,
useI18n
})
};
}
//# sourceMappingURL=vue-i18n.js.map
@@ -0,0 +1 @@
{"version":3,"file":"vue-i18n.js","names":["useProxiedModel","toRef","watch","useProvided","props","prop","provided","internal","value","v","inferDecimalSeparator","format","includes","createProvideFunction","data","current","fallback","messages","i18n","useI18n","locale","fallbackLocale","useScope","legacy","inheritLocale","name","decimalSeparator","n","t","key","_len","arguments","length","params","Array","_key","provide","createVueI18nAdapter","_ref","global","_len2","_key2"],"sources":["../../../src/locale/adapters/vue-i18n.ts"],"sourcesContent":["// Composables\nimport { useProxiedModel } from '@/composables/proxiedModel'\n\n// Utilities\nimport { toRef, watch } from 'vue'\n\n// Types\nimport type { Ref } from 'vue'\nimport type { I18n, useI18n } from 'vue-i18n'\nimport type { LocaleInstance, LocaleMessages, LocaleOptions } from '@/composables/locale'\n\ntype VueI18nAdapterParams = {\n i18n: I18n<any, {}, {}, string, false>\n useI18n: typeof useI18n\n}\n\nfunction useProvided <T> (props: any, prop: string, provided: Ref<T>) {\n const internal = useProxiedModel(props, prop)\n\n internal.value = props[prop] ?? provided.value\n\n watch(provided, v => {\n if (props[prop] == null) {\n internal.value = v\n }\n })\n\n return internal as Ref<T>\n}\n\nfunction inferDecimalSeparator (format: (v: number) => string) {\n return format(0.1).includes(',') ? ',' : '.'\n}\n\nfunction createProvideFunction (data: {\n current: Ref<string>\n fallback: Ref<string>\n messages: Ref<LocaleMessages>\n useI18n: typeof useI18n\n}) {\n return (props: LocaleOptions): LocaleInstance => {\n const current = useProvided(props, 'locale', data.current)\n const fallback = useProvided(props, 'fallback', data.fallback)\n const messages = useProvided(props, 'messages', data.messages)\n\n const i18n = data.useI18n({\n locale: current.value,\n fallbackLocale: fallback.value,\n messages: messages.value as any,\n useScope: 'local',\n legacy: false,\n inheritLocale: false,\n })\n\n watch(current, v => {\n i18n.locale.value = v\n })\n\n return {\n name: 'vue-i18n',\n current,\n fallback,\n messages,\n decimalSeparator: toRef(() => props.decimalSeparator ?? inferDecimalSeparator(i18n.n)),\n t: (key: string, ...params: unknown[]) => i18n.t(key, params),\n n: i18n.n,\n provide: createProvideFunction({ current, fallback, messages, useI18n: data.useI18n }),\n }\n }\n}\n\nexport function createVueI18nAdapter ({ i18n, useI18n }: VueI18nAdapterParams): LocaleInstance {\n const current = i18n.global.locale\n const fallback = i18n.global.fallbackLocale as Ref<any>\n const messages = i18n.global.messages\n\n return {\n name: 'vue-i18n',\n current,\n fallback,\n messages,\n decimalSeparator: toRef(() => inferDecimalSeparator(i18n.global.n)),\n t: (key: string, ...params: unknown[]) => i18n.global.t(key, params),\n n: i18n.global.n,\n provide: createProvideFunction({ current, fallback, messages, useI18n }),\n }\n}\n"],"mappings":"AAAA;AAAA,SACSA,eAAe,6CAExB;AACA,SAASC,KAAK,EAAEC,KAAK,QAAQ,KAAK;;AAElC;;AAUA,SAASC,WAAWA,CAAMC,KAAU,EAAEC,IAAY,EAAEC,QAAgB,EAAE;EACpE,MAAMC,QAAQ,GAAGP,eAAe,CAACI,KAAK,EAAEC,IAAI,CAAC;EAE7CE,QAAQ,CAACC,KAAK,GAAGJ,KAAK,CAACC,IAAI,CAAC,IAAIC,QAAQ,CAACE,KAAK;EAE9CN,KAAK,CAACI,QAAQ,EAAEG,CAAC,IAAI;IACnB,IAAIL,KAAK,CAACC,IAAI,CAAC,IAAI,IAAI,EAAE;MACvBE,QAAQ,CAACC,KAAK,GAAGC,CAAC;IACpB;EACF,CAAC,CAAC;EAEF,OAAOF,QAAQ;AACjB;AAEA,SAASG,qBAAqBA,CAAEC,MAA6B,EAAE;EAC7D,OAAOA,MAAM,CAAC,GAAG,CAAC,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG;AAC9C;AAEA,SAASC,q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,CAAC,EAAET,IAAI,CAACS,CAAC;MACTS,OAAO,EAAEvB,qBAAqB,CAAC;QAAEE,OAAO;QAAEC,QAAQ;QAAEC,QAAQ;QAAEE,OAAO,EAAEL,IAAI,CAACK;MAAQ,CAAC;IACvF,CAAC;EACH,CAAC;AACH;AAEA,OAAO,SAASkB,oBAAoBA,CAAAC,IAAA,EAA2D;EAAA,IAAzD;IAAEpB,IAAI;IAAEC;EAA8B,CAAC,GAAAmB,IAAA;EAC3E,MAAMvB,OAAO,GAAGG,IAAI,CAACqB,MAAM,CAACnB,MAAM;EAClC,MAAMJ,QAAQ,GLine truncated
@@ -0,0 +1,2 @@
import type { LocaleInstance, LocaleOptions } from '../../composables/locale.js';
export declare function createVuetifyAdapter(options?: LocaleOptions): LocaleInstance;
@@ -0,0 +1,104 @@
// Composables
import { useProxiedModel } from "../../composables/proxiedModel.js"; // Utilities
import { ref, shallowRef, toRef, watch } from 'vue';
import { consoleError, consoleWarn, getObjectValueByPath } from "../../util/index.js"; // Locales
import en from "../en.js"; // Types
const LANG_PREFIX = '$vuetify.';
const replace = (str, params) => {
return str.replace(/\{(\d+)\}/g, (match, index) => {
return String(params[Number(index)]);
});
};
const createTranslateFunction = (current, fallback, messages) => {
return function (key) {
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
params[_key - 1] = arguments[_key];
}
if (!key.startsWith(LANG_PREFIX)) {
return replace(key, params);
}
const shortKey = key.replace(LANG_PREFIX, '');
const currentLocale = current.value && messages.value[current.value];
const fallbackLocale = fallback.value && messages.value[fallback.value];
let str = getObjectValueByPath(currentLocale, shortKey, null);
if (!str) {
consoleWarn(`Translation key "${key}" not found in "${current.value}", trying fallback locale`);
str = getObjectValueByPath(fallbackLocale, shortKey, null);
}
if (!str) {
consoleError(`Translation key "${key}" not found in fallback`);
str = key;
}
if (typeof str !== 'string') {
consoleError(`Translation key "${key}" has a non-string value`);
str = key;
}
return replace(str, params);
};
};
function createNumberFunction(current, fallback) {
return (value, options) => {
const numberFormat = new Intl.NumberFormat([current.value, fallback.value], options);
return numberFormat.format(value);
};
}
function inferDecimalSeparator(current, fallback) {
const format = createNumberFunction(current, fallback);
return format(0.1).includes(',') ? ',' : '.';
}
function useProvided(props, prop, provided) {
const internal = useProxiedModel(props, prop, props[prop] ?? provided.value);
// TODO: Remove when defaultValue works
internal.value = props[prop] ?? provided.value;
watch(provided, v => {
if (props[prop] == null) {
internal.value = provided.value;
}
});
return internal;
}
function createProvideFunction(state) {
return props => {
const current = useProvided(props, 'locale', state.current);
const fallback = useProvided(props, 'fallback', state.fallback);
const messages = useProvided(props, 'messages', state.messages);
return {
name: 'vuetify',
current,
fallback,
messages,
decimalSeparator: toRef(() => inferDecimalSeparator(current, fallback)),
t: createTranslateFunction(current, fallback, messages),
n: createNumberFunction(current, fallback),
provide: createProvideFunction({
current,
fallback,
messages
})
};
};
}
export function createVuetifyAdapter(options) {
const current = shallowRef(options?.locale ?? 'en');
const fallback = shallowRef(options?.fallback ?? 'en');
const messages = ref({
en,
...options?.messages
});
return {
name: 'vuetify',
current,
fallback,
messages,
decimalSeparator: toRef(() => options?.decimalSeparator ?? inferDecimalSeparator(current, fallback)),
t: createTranslateFunction(current, fallback, messages),
n: createNumberFunction(current, fallback),
provide: createProvideFunction({
current,
fallback,
messages
})
};
}
//# sourceMappingURL=vuetify.js.map
@@ -0,0 +1 @@
{"version":3,"file":"vuetify.js","names":["useProxiedModel","ref","shallowRef","toRef","watch","consoleError","consoleWarn","getObjectValueByPath","en","LANG_PREFIX","replace","str","params","match","index","String","Number","createTranslateFunction","current","fallback","messages","key","_len","arguments","length","Array","_key","startsWith","shortKey","currentLocale","value","fallbackLocale","createNumberFunction","options","numberFormat","Intl","NumberFormat","format","inferDecimalSeparator","includes","useProvided","props","prop","provided","internal","v","createProvideFunction","state","name","decimalSeparator","t","n","provide","createVuetifyAdapter","locale"],"sources":["../../../src/locale/adapters/vuetify.ts"],"sourcesContent":["// Composables\nimport { useProxiedModel } from '@/composables/proxiedModel'\n\n// Utilities\nimport { ref, shallowRef, toRef, watch } from 'vue'\nimport { consoleError, consoleWarn, getObjectValueByPath } from '@/util'\n\n// Locales\nimport en from '@/locale/en'\n\n// Types\nimport type { Ref } from 'vue'\nimport type { LocaleInstance, LocaleMessages, LocaleOptions } from '@/composables/locale'\n\nconst LANG_PREFIX = '$vuetify.'\n\nconst replace = (str: string, params: unknown[]) => {\n return str.replace(/\\{(\\d+)\\}/g, (match: string, index: string) => {\n return String(params[Number(index)])\n })\n}\n\nconst createTranslateFunction = (\n current: Ref<string>,\n fallback: Ref<string>,\n messages: Ref<LocaleMessages>,\n) => {\n return (key: string, ...params: unknown[]) => {\n if (!key.startsWith(LANG_PREFIX)) {\n return replace(key, params)\n }\n\n const shortKey = key.replace(LANG_PREFIX, '')\n const currentLocale = current.value && messages.value[current.value]\n const fallbackLocale = fallback.value && messages.value[fallback.value]\n\n let str: string = getObjectValueByPath(currentLocale, shortKey, null)\n\n if (!str) {\n consoleWarn(`Translation key \"${key}\" not found in \"${current.value}\", trying fallback locale`)\n str = getObjectValueByPath(fallbackLocale, shortKey, null)\n }\n\n if (!str) {\n consoleError(`Translation key \"${key}\" not found in fallback`)\n str = key\n }\n\n if (typeof str !== 'string') {\n consoleError(`Translation key \"${key}\" has a non-string value`)\n str = key\n }\n\n return replace(str, params)\n }\n}\n\nfunction createNumberFunction (current: Ref<string>, fallback: Ref<string>) {\n return (value: number, options?: Intl.NumberFormatOptions) => {\n const numberFormat = new Intl.NumberFormat([current.value, fallback.value], options)\n\n return numberFormat.format(value)\n }\n}\n\nfunction inferDecimalSeparator (current: Ref<string>, fallback: Ref<string>) {\n const format = createNumberFunction(current, fallback)\n return format(0.1).includes(',') ? ',' : '.'\n}\n\nfunction useProvided <T> (props: any, prop: string, provided: Ref<T>) {\n const internal = useProxiedModel(props, prop, props[prop] ?? provided.value)\n\n // TODO: Remove when defaultValue works\n internal.value = props[prop] ?? provided.value\n\n watch(provided, v => {\n if (props[prop] == null) {\n internal.value = provided.value\n }\n })\n\n return internal as Ref<T>\n}\n\nfunction createProvideFunction (state: { current: Ref<string>, fallback: Ref<string>, messages: Ref<LocaleMessages> }) {\n return (props: LocaleOptions): LocaleInstance => {\n const current = useProvided(props, 'locale', state.current)\n const fallback = useProvided(props, 'fallback', state.fallback)\n const messages = useProvided(props, 'messages', state.messages)\n\n return {\n name: 'vuetify',\n current,\n fallback,\n messages,\n decimalSeparator: toRef(() => inferDecimalSeparator(current, fallback)),\n t: createTranslateFunction(current, fallback, messages),\n n: createNumberFunction(current, fallback),\n provide: createProvideFunction({ current, fallback, messages }),\n }\n }\n}\n\nexport function createVuetifyAdapter (options?: LocaleOptions): LocaleInstance {\n const current = shallowRef(options?.locale ?? 'en')\n const fallback = shallowRef(options?.fallback ?? 'en')\n const messages = ref({ en, ...options?.messages })\n\n return {\n name: 'vuetify',\n current,\n fallback,\n messages,\n decimalSeparator: toRef(() => options?.decimalSeparator ?? inferDecimalSeparator(current, fallback)),\n t: createTranslateFunction(current, fallback, messages),\n n: createNumberFunction(current, fallback),\n provide: createProvideFunction({ current, fallback, messages }),\n }\n}\n"],"mappings":"AAAA;AAAA,SACSA,eAAe,6CAExB;AACA,SAASC,GAAG,EAAEC,UAAU,EAAEC,KAAK,EAAEC,KAAK,QAAQ,KAAK;AAAA,SAC1CC,YAAY,EAAEC,WAAW,EAAEC,oBAAoB,+BAExD;AAAA,OACOC,EAAE,kBAET;AAIA,MAAMC,WAAW,GAAG,WAAW;AAE/B,MAAMC,OAAO,GAAGA,CAACC,GAAW,EAAEC,MAAiB,KAAK;EAClD,OAAOD,GAAG,CAACD,OAAO,CAAC,YAAY,EAAE,CAACG,KAAa,EAAEC,KAAa,KAAK;IACjE,OAAOC,MAAM,CAACH,Line truncated