mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Add support for i18n in more places.
This commit is contained in:
parent
6ce9f38d15
commit
90fb99db71
8 changed files with 55 additions and 14 deletions
13
src/App.vue
13
src/App.vue
|
@ -58,6 +58,19 @@ export default {
|
||||||
window.db = e.target.result;
|
window.db = e.target.result;
|
||||||
};
|
};
|
||||||
} else console.log("This browser doesn't support IndexedDB");
|
} else console.log("This browser doesn't support IndexedDB");
|
||||||
|
|
||||||
|
const App = this;
|
||||||
|
|
||||||
|
(async function() {
|
||||||
|
const locale = App.getPreferenceString("hl", "en");
|
||||||
|
if (window.i18n.global.locale.value !== locale) {
|
||||||
|
if (!window.i18n.global.availableLocales.includes(locale)) {
|
||||||
|
const messages = await import("@/locales/" + locale + ".json").then(module => module.default);
|
||||||
|
window.i18n.global.setLocaleMessage(locale, messages);
|
||||||
|
}
|
||||||
|
window.i18n.global.locale.value = locale;
|
||||||
|
}
|
||||||
|
})();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -32,16 +32,16 @@
|
||||||
<router-link to="/preferences">Preferences</router-link>
|
<router-link to="/preferences">Preferences</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="shouldShowLogin">
|
<li v-if="shouldShowLogin">
|
||||||
<router-link to="/login">Login</router-link>
|
<router-link to="/login" v-t="'titles.login'" />
|
||||||
</li>
|
</li>
|
||||||
<li v-if="shouldShowLogin">
|
<li v-if="shouldShowLogin">
|
||||||
<router-link to="/register">Register</router-link>
|
<router-link to="/register" v-t="'titles.register'" />
|
||||||
</li>
|
</li>
|
||||||
<li v-if="shouldShowHistory">
|
<li v-if="shouldShowHistory">
|
||||||
<router-link to="/history">History</router-link>
|
<router-link to="/history">History</router-link>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="authenticated">
|
<li v-if="authenticated">
|
||||||
<router-link to="/feed">Feed</router-link>
|
<router-link to="/feed" v-t="'titles.feed'" />
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -307,7 +307,7 @@ export default {
|
||||||
this.player = undefined;
|
this.player = undefined;
|
||||||
}
|
}
|
||||||
if (this.hotkeys) this.hotkeys.unbind();
|
if (this.hotkeys) this.hotkeys.unbind();
|
||||||
this.$refs.container.querySelectorAll("div").forEach(node => node.remove());
|
if (this.$refs.container) this.$refs.container.querySelectorAll("div").forEach(node => node.remove());
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<button class="uk-button uk-button-text" @click="$router.go(-1) || $router.push('/')">
|
<button class="uk-button uk-button-text" @click="$router.go(-1) || $router.push('/')">
|
||||||
<font-awesome-icon icon="chevron-left" /> Back
|
<font-awesome-icon icon="chevron-left" /> Back
|
||||||
</button>
|
</button>
|
||||||
<span><h1 class="uk-text-bold uk-text-center">Preferences</h1></span>
|
<span><h1 class="uk-text-bold uk-text-center" v-t="'titles.preferences'"/></span>
|
||||||
<span />
|
<span />
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
@ -92,6 +92,12 @@
|
||||||
<b>Store Watch History</b>
|
<b>Store Watch History</b>
|
||||||
<br />
|
<br />
|
||||||
<input class="uk-checkbox" v-model="watchHistory" @change="onChange($event)" type="checkbox" />
|
<input class="uk-checkbox" v-model="watchHistory" @change="onChange($event)" type="checkbox" />
|
||||||
|
<br />
|
||||||
|
<b>Language Selection</b>
|
||||||
|
<br />
|
||||||
|
<select class="uk-select uk-width-auto" v-model="selectedLanguage" @change="onChange($event)">
|
||||||
|
<option :key="language.code" v-for="language in languages" :value="language.code">{{ language.name }}</option>
|
||||||
|
</select>
|
||||||
<h2>Instances List</h2>
|
<h2>Instances List</h2>
|
||||||
<table class="uk-table">
|
<table class="uk-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -152,10 +158,15 @@ export default {
|
||||||
showComments: true,
|
showComments: true,
|
||||||
minimizeDescription: false,
|
minimizeDescription: false,
|
||||||
watchHistory: false,
|
watchHistory: false,
|
||||||
|
selectedLanguage: "en",
|
||||||
|
languages: [
|
||||||
|
{ code: "en", name: "English" },
|
||||||
|
{ code: "fr", name: "French" },
|
||||||
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
document.title = "Preferences - Piped";
|
document.title = this.$t("titles.preferences") + " - Piped";
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
|
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
|
||||||
|
@ -179,6 +190,13 @@ export default {
|
||||||
cdn: split[3].trim(),
|
cdn: split[3].trim(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (this.instances.filter(instance => instance.apiurl == this.apiUrl()).length > 0)
|
||||||
|
this.instances.push({
|
||||||
|
name: "Custom Instance",
|
||||||
|
apiurl: this.apiUrl(),
|
||||||
|
locations: "Unknown",
|
||||||
|
cdn: "Unknown",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -229,6 +247,7 @@ export default {
|
||||||
this.showComments = this.getPreferenceBoolean("comments", true);
|
this.showComments = this.getPreferenceBoolean("comments", true);
|
||||||
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
|
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
|
||||||
this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
|
this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
|
||||||
|
this.selectedLanguage = this.getPreferenceString("hl", "en");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -238,7 +257,8 @@ export default {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.getPreferenceString("theme", "dark") !== this.selectedTheme ||
|
this.getPreferenceString("theme", "dark") !== this.selectedTheme ||
|
||||||
this.getPreferenceBoolean("watchHistory", false) != this.watchHistory
|
this.getPreferenceBoolean("watchHistory", false) != this.watchHistory ||
|
||||||
|
this.getPreferenceString("hl", "en") !== this.selectedLanguage
|
||||||
)
|
)
|
||||||
shouldReload = true;
|
shouldReload = true;
|
||||||
|
|
||||||
|
@ -265,6 +285,7 @@ export default {
|
||||||
localStorage.setItem("comments", this.showComments);
|
localStorage.setItem("comments", this.showComments);
|
||||||
localStorage.setItem("minimizeDescription", this.minimizeDescription);
|
localStorage.setItem("minimizeDescription", this.minimizeDescription);
|
||||||
localStorage.setItem("watchHistory", this.watchHistory);
|
localStorage.setItem("watchHistory", this.watchHistory);
|
||||||
|
localStorage.setItem("hl", this.selectedLanguage);
|
||||||
|
|
||||||
if (shouldReload) window.location.reload();
|
if (shouldReload) window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<h1 class="uk-text-bold uk-text-center">{{ $t("titles.trending") }}</h1>
|
<h1 class="uk-text-bold uk-text-center" v-t="'titles.trending'" />
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
class="uk-margin-small-left uk-button uk-button-small"
|
class="uk-margin-small-left uk-button uk-button-small"
|
||||||
style="background: #222"
|
style="background: #222"
|
||||||
>
|
>
|
||||||
<b>Watch on </b>
|
<b>{{ $t("player.watch_on") }} </b>
|
||||||
<font-awesome-icon class="uk-margin-small-right" :icon="['fab', 'youtube']"></font-awesome-icon>
|
<font-awesome-icon class="uk-margin-small-right" :icon="['fab', 'youtube']"></font-awesome-icon>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
class="uk-margin-small-left uk-button uk-button-small"
|
class="uk-margin-small-left uk-button uk-button-small"
|
||||||
style="background: #222"
|
style="background: #222"
|
||||||
>
|
>
|
||||||
<b>Watch on LBRY</b>
|
<b>{{ $t("player.watch_on") }} LBRY</b>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
style="background: #222"
|
style="background: #222"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{{ subscribed ? "Unsubscribe" : "Subscribe" }}
|
{{ subscribed ? $t("actions.unsubscribe") : $t("actions.subscribe") }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,12 @@
|
||||||
"register": "Register",
|
"register": "Register",
|
||||||
"feed": "Feed",
|
"feed": "Feed",
|
||||||
"preferences": "Preferences"
|
"preferences": "Preferences"
|
||||||
|
},
|
||||||
|
"player": {
|
||||||
|
"watch_on": "Watch on"
|
||||||
|
},
|
||||||
|
"actions": {
|
||||||
|
"subscribe": "Subscribe",
|
||||||
|
"unsubscribe": "Unsubscribe"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ const mixin = {
|
||||||
getPreferenceBoolean(key, defaultVal) {
|
getPreferenceBoolean(key, defaultVal) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
if (
|
||||||
(value = this.$route.query[key]) !== undefined ||
|
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||||
(localStorage && (value = localStorage.getItem(key)) !== null)
|
(localStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
switch (String(value).toLowerCase()) {
|
switch (String(value).toLowerCase()) {
|
||||||
|
@ -124,7 +124,7 @@ const mixin = {
|
||||||
getPreferenceString(key, defaultVal) {
|
getPreferenceString(key, defaultVal) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
if (
|
||||||
(value = this.$route.query[key]) !== undefined ||
|
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||||
(localStorage && (value = localStorage.getItem(key)) !== null)
|
(localStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
return value;
|
return value;
|
||||||
|
@ -133,7 +133,7 @@ const mixin = {
|
||||||
getPreferenceNumber(key, defaultVal) {
|
getPreferenceNumber(key, defaultVal) {
|
||||||
var value;
|
var value;
|
||||||
if (
|
if (
|
||||||
(value = this.$route.query[key]) !== undefined ||
|
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||||
(localStorage && (value = localStorage.getItem(key)) !== null)
|
(localStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
) {
|
) {
|
||||||
return Number(value);
|
return Number(value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue