Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

fix: compare all browser languages with available offerings.

Matt Kilgorea6aafeb3746d
diff --git a/backend/go.sum b/backend/go.sum
index ac151ff6..53402d7b 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -111,6 +111,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
+github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
@@ -120,6 +122,8 @@ github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJm
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/olahol/melody v1.1.4 h1:RQHfKZkQmDxI0+SLZRNBCn4LiXdqxLKRGSkT8Dyoe/E=
github.com/olahol/melody v1.1.4/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=
+github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
+github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
@@ -137,6 +141,10 @@ github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
+github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
+github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
diff --git a/frontend/locales/zh_Hans.json b/frontend/locales/zh-Hans.json
similarity index 100%
rename from frontend/locales/zh_Hans.json
rename to frontend/locales/zh-Hans.json
diff --git a/frontend/locales/zh_Hant.json b/frontend/locales/zh-Hant.json
similarity index 100%
rename from frontend/locales/zh_Hant.json
rename to frontend/locales/zh-Hant.json
diff --git a/frontend/plugins/i18n.ts b/frontend/plugins/i18n.ts
index fb23642d..d7650cb5 100644
--- a/frontend/plugins/i18n.ts
+++ b/frontend/plugins/i18n.ts
@@ -1,19 +1,22 @@
import type { CompileError, MessageCompiler, MessageContext } from "vue-i18n";
import { createI18n } from "vue-i18n";
import { IntlMessageFormat } from "intl-messageformat";
+import { messages } from "./messages";
export default defineNuxtPlugin(({ vueApp }) => {
function checkDefaultLanguage() {
let matched = null;
- const languages = Object.getOwnPropertyNames(messages())
+ const languages = Object.getOwnPropertyNames(messages());
languages.forEach(lang => {
- if (lang === navigator.language.replace('-', '_')) {
- matched = lang;
- }
+ navigator.languages.forEach(language => {
+ if (lang === language) {
+ matched = lang;
+ }
+ });
});
if (!matched) {
languages.forEach(lang => {
- const languagePartials = navigator.language.split('-')[0]
+ const languagePartials = navigator.language.split("-")[0];
if (lang === languagePartials) {
matched = lang;
}
@@ -51,13 +54,3 @@ export const messageCompiler: MessageCompiler = (message, { locale, key, onError
return () => key;
}
};
-
-export const messages: Object = () => {
- let messages = {};
- const modules = import.meta.glob('~//locales/**.json', { eager: true });
- for (const path in modules) {
- const key = path.slice(9, -5);
- messages[key] = modules[path];
- }
- return messages;
-};
diff --git a/frontend/plugins/messages.ts b/frontend/plugins/messages.ts
new file mode 100644
index 00000000..767aca66
--- /dev/null
+++ b/frontend/plugins/messages.ts
@@ -0,0 +1,9 @@
+export const messages: Object = () => {
+ const messages = {};
+ const modules = import.meta.glob("~//locales/**.json", { eager: true });
+ for (const path in modules) {
+ const key = path.slice(9, -5);
+ messages[key] = modules[path];
+ }
+ return messages;
+};