From 877a567a1554362e42dd73f6895215dab1aa6c72 Mon Sep 17 00:00:00 2001 From: dragongoose Date: Mon, 3 Jul 2023 19:06:28 -0400 Subject: [PATCH] Complete translation support --- src/components/LanguageSwitcher.vue | 6 +++--- src/i18n.ts | 8 ++++---- src/mixins.ts | 2 +- src/views/UserView.vue | 8 ++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/LanguageSwitcher.vue b/src/components/LanguageSwitcher.vue index 9fe7582..f104f68 100644 --- a/src/components/LanguageSwitcher.vue +++ b/src/components/LanguageSwitcher.vue @@ -12,20 +12,20 @@ export default { setup() { return { - langs: ['en', 'es'], + langs: ['en-US', 'es-ES'], names: ['English', 'EspaƱol'] } }, mounted() { - const langs = ['en', 'es'] const savedLocale = localStorage.getItem("language") - if (savedLocale != null && langs.includes(savedLocale)) { + if (savedLocale != null && this.langs.includes(savedLocale)) { this.$i18n.locale = savedLocale } }, methods: { onChange() { localStorage.setItem("language", this.$i18n.locale) + window.location.reload() } } } diff --git a/src/i18n.ts b/src/i18n.ts index dcdaaca..473d4e4 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -4,11 +4,11 @@ import es from '@/locales/es.json' export default createI18n({ legacy: false, - locale: import.meta.env.VUE_APP_I18N_LOCALE || 'en', - fallbackLocale: import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', + locale: import.meta.env.VUE_APP_I18N_LOCALE || 'en-US', + fallbackLocale: import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en-US', globalInjection: true, messages: { - 'en': en, - 'es': es + 'en-US': en, + 'es-ES': es } }) diff --git a/src/mixins.ts b/src/mixins.ts index 53bf2a1..ec0f00b 100644 --- a/src/mixins.ts +++ b/src/mixins.ts @@ -22,7 +22,7 @@ export async function getEndpoint(endpoint: string) { let data let language = localStorage.getItem("language") if (language === null) { - language = "en" + language = "en-US" } try { diff --git a/src/views/UserView.vue b/src/views/UserView.vue index b1860fc..68f6483 100644 --- a/src/views/UserView.vue +++ b/src/views/UserView.vue @@ -15,11 +15,19 @@ export default { inject: ["rootBackendUrl"], async setup() { const route = useRoute() + const username = route.params.username const data = ref() const status = ref<"ok" | "error">() + const rootBackendUrl = inject('rootBackendUrl') const videoOptions = { autoplay: true, controls: true, + sources: [ + { + src: `${rootBackendUrl}/proxy/stream/${username}/hls.m3u8`, + type: 'application/vnd.apple.mpegurl' + } + ], fluid: true }