0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2025-01-25 21:58:44 -05:00

Complete translation support

This commit is contained in:
dragongoose 2023-07-03 19:06:28 -04:00
parent 5b046024b6
commit 877a567a15
No known key found for this signature in database
GPG key ID: 50DB99B921579009
4 changed files with 16 additions and 8 deletions

View file

@ -12,20 +12,20 @@
export default { export default {
setup() { setup() {
return { return {
langs: ['en', 'es'], langs: ['en-US', 'es-ES'],
names: ['English', 'Español'] names: ['English', 'Español']
} }
}, },
mounted() { mounted() {
const langs = ['en', 'es']
const savedLocale = localStorage.getItem("language") const savedLocale = localStorage.getItem("language")
if (savedLocale != null && langs.includes(savedLocale)) { if (savedLocale != null && this.langs.includes(savedLocale)) {
this.$i18n.locale = savedLocale this.$i18n.locale = savedLocale
} }
}, },
methods: { methods: {
onChange() { onChange() {
localStorage.setItem("language", this.$i18n.locale) localStorage.setItem("language", this.$i18n.locale)
window.location.reload()
} }
} }
} }

View file

@ -4,11 +4,11 @@ import es from '@/locales/es.json'
export default createI18n({ export default createI18n({
legacy: false, legacy: false,
locale: import.meta.env.VUE_APP_I18N_LOCALE || 'en', locale: import.meta.env.VUE_APP_I18N_LOCALE || 'en-US',
fallbackLocale: import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', fallbackLocale: import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en-US',
globalInjection: true, globalInjection: true,
messages: { messages: {
'en': en, 'en-US': en,
'es': es 'es-ES': es
} }
}) })

View file

@ -22,7 +22,7 @@ export async function getEndpoint(endpoint: string) {
let data let data
let language = localStorage.getItem("language") let language = localStorage.getItem("language")
if (language === null) { if (language === null) {
language = "en" language = "en-US"
} }
try { try {

View file

@ -15,11 +15,19 @@ export default {
inject: ["rootBackendUrl"], inject: ["rootBackendUrl"],
async setup() { async setup() {
const route = useRoute() const route = useRoute()
const username = route.params.username
const data = ref<StreamerData>() const data = ref<StreamerData>()
const status = ref<"ok" | "error">() const status = ref<"ok" | "error">()
const rootBackendUrl = inject('rootBackendUrl')
const videoOptions = { const videoOptions = {
autoplay: true, autoplay: true,
controls: true, controls: true,
sources: [
{
src: `${rootBackendUrl}/proxy/stream/${username}/hls.m3u8`,
type: 'application/vnd.apple.mpegurl'
}
],
fluid: true fluid: true
} }