mirror of
https://github.com/TeamPiped/Piped.git
synced 2025-12-26 06:30:21 +00:00
Add i18n translations. (#381)
* Initial prototype. * Add support for i18n in more places.
This commit is contained in:
24
src/main.js
24
src/main.js
@@ -42,6 +42,9 @@ import en from "javascript-time-ago/locale/en";
|
||||
|
||||
TimeAgo.addDefaultLocale(en);
|
||||
|
||||
import { createI18n } from "vue-i18n";
|
||||
import enLocale from "@/locales/en.json";
|
||||
|
||||
const timeAgo = new TimeAgo("en-US");
|
||||
|
||||
import("./registerServiceWorker");
|
||||
@@ -104,10 +107,10 @@ const mixin = {
|
||||
getPreferenceBoolean(key, defaultVal) {
|
||||
var value;
|
||||
if (
|
||||
(value = this.$route.query[key]) !== undefined ||
|
||||
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||
(localStorage && (value = localStorage.getItem(key)) !== null)
|
||||
) {
|
||||
switch (String(value)) {
|
||||
switch (String(value).toLowerCase()) {
|
||||
case "true":
|
||||
case "1":
|
||||
case "on":
|
||||
@@ -121,7 +124,7 @@ const mixin = {
|
||||
getPreferenceString(key, defaultVal) {
|
||||
var value;
|
||||
if (
|
||||
(value = this.$route.query[key]) !== undefined ||
|
||||
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||
(localStorage && (value = localStorage.getItem(key)) !== null)
|
||||
) {
|
||||
return value;
|
||||
@@ -130,7 +133,7 @@ const mixin = {
|
||||
getPreferenceNumber(key, defaultVal) {
|
||||
var value;
|
||||
if (
|
||||
(value = this.$route.query[key]) !== undefined ||
|
||||
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||
(localStorage && (value = localStorage.getItem(key)) !== null)
|
||||
) {
|
||||
return Number(value);
|
||||
@@ -202,7 +205,20 @@ const mixin = {
|
||||
},
|
||||
};
|
||||
|
||||
const i18n = createI18n({
|
||||
globalInjection: true,
|
||||
legacy: false,
|
||||
locale: "en",
|
||||
fallbackLocale: "en",
|
||||
messages: {
|
||||
en: enLocale,
|
||||
},
|
||||
});
|
||||
|
||||
window.i18n = i18n;
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(i18n);
|
||||
app.use(router);
|
||||
app.mixin(mixin);
|
||||
app.component("font-awesome-icon", FontAwesomeIcon);
|
||||
|
||||
Reference in New Issue
Block a user