Skip to content

Commit

Permalink
better fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
NeloBlivion authored Sep 29, 2023
1 parent 00b797a commit 159c370
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/components/media/SongFrame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<script lang="ts">
import Youtube from "@/components/player/YoutubePlayer.vue";
import { langConversion } from "@/utils/consts";
import { getYTLangFromState } from "@/utils/functions";
export default {
name: "SongFrame",
Expand Down Expand Up @@ -61,8 +61,7 @@ export default {
return this.isBackground ? "song-player-container-background" : "song-player-container";
},
getLang() {
const lang = this.$store.state.settings.lang;
return langConversion[lang] || lang;
return getYTLangFromState(this.$store.state);
},
},
watch: {
Expand Down
5 changes: 2 additions & 3 deletions src/components/multiview/VideoCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<script>
import { mapMutations } from "vuex";
import { langConversion } from "@/utils/consts";
import { getYTLangFromState } from "@/utils/functions";
import YoutubePlayer from "../player/YoutubePlayer.vue";
import CellMixin from "./CellMixin";
import CellControl from "./CellControl.vue";
Expand Down Expand Up @@ -126,8 +126,7 @@ export default {
return this.playbackRate !== 1;
},
getLang() {
const lang = this.$store.state.settings.lang;
return langConversion[lang] || lang;
return getYTLangFromState(this.$store.state);
},
},
watch: {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/functions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TL_LANGS,
VIDEO_URL_REGEX,
TWITCH_VIDEO_URL_REGEX,
langConversion,
/*
TWITCH_UNLIVE_VIDEO_URL_REGEX,
TWITCAST_VIDEO_URL_REGEX,
Expand Down Expand Up @@ -75,6 +76,11 @@ export function getLang(weblang) {
return "en";
}

export function getYTLangFromState(state) {
const lang = state.settings.lang;
return langConversion[lang] || lang.split("-")[0].toLowerCase();
}

export function getBannerImages(url) {
const base = `${url.split("=")[0]}=`;
return {
Expand Down
5 changes: 2 additions & 3 deletions src/views/EditVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ import WatchComments from "@/components/watch/WatchComments.vue";
import VideoEditSongs from "@/components/edit/VideoEditSongs.vue";
import VideoEditMentions from "@/components/edit/VideoEditMentions.vue";
import CommentSongParser from "@/components/media/CommentSongParser.vue";
import { decodeHTMLEntities, syncState } from "@/utils/functions";
import { decodeHTMLEntities, syncState, getYTLangFromState } from "@/utils/functions";
// import { dayjs } from "@/utils/time";
import api from "@/utils/backend-api";
Expand Down Expand Up @@ -251,8 +251,7 @@ export default {
return this.$store.state.userdata?.user?.role;
},
getLang() {
const lang = this.$store.state.settings.lang;
return langConversion[lang] || lang;
return getYTLangFromState(this.$store.state);
},
},
watch: {
Expand Down
6 changes: 2 additions & 4 deletions src/views/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ import WatchHighlights from "@/components/watch/WatchHighlights.vue";
import WatchToolBar from "@/components/watch/WatchToolbar.vue";
import WatchComments from "@/components/watch/WatchComments.vue";
import UploadScript from "@/components/tlscriptmanager/UploadScript.vue";
import { langConversion } from "@/utils/consts";
import { decodeHTMLEntities, syncState } from "@/utils/functions";
import { decodeHTMLEntities, syncState, getYTLangFromState} from "@/utils/functions";
import { mapState } from "vuex";
import { mdiOpenInNew, mdiDockLeft, mdiThumbUp } from "@mdi/js";
Expand Down Expand Up @@ -275,8 +274,7 @@ export default {
return this.$store.state.uploadPanel;
},
getLang() {
const lang = this.$store.state.settings.lang;
return langConversion[lang] || lang;
return getYTLangFromState(this.$store.state);
},
},
watch: {
Expand Down

0 comments on commit 159c370

Please sign in to comment.