Skip to content

Commit

Permalink
implement default caption language?
Browse files Browse the repository at this point in the history
  • Loading branch information
NeloBlivion authored Sep 29, 2023
1 parent 4622b22 commit ed211c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/player/YoutubePlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<script>
import player from "youtube-player";
import PlayerMixin from "./PlayerMixin";
import langConversion from "@/utils/consts";
const UNSTARTED = -1;
const ENDED = 0;
Expand Down Expand Up @@ -64,6 +65,7 @@ export default {
videoId: this.videoId,
playerVars: this.playerVars,
origin: window.origin,
"cc_lang_pref": this.getLang(),
});
this.player.on("ready", (e) => this.playerReady(e.target));
Expand Down Expand Up @@ -117,6 +119,10 @@ export default {
isMuted() {
return this.player.isMuted();
},
getLang() {
const lang = this.$store.state.settings.lang;
return langConversion[lang] || lang;
},
seekTo(t) {
this.player.seekTo(t);
},
Expand Down
9 changes: 9 additions & 0 deletions src/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ export const TL_LANGS = Object.freeze([
// MISSING: "missing",
// };


// Language code conversion for YouTube frame
export const langConversion = Object.freeze({
"lol-PEKO": "en",
"lol-UWU": "en",
"zh": "zh-Hant",
"zh-CN": "zh-Hans"
});

export const companionExtensionId = "jkdnofimdhpbhdjbcdlgnccfjjkidlgp";

export const MESSAGE_TYPES = Object.freeze({
Expand Down

0 comments on commit ed211c2

Please sign in to comment.