From 636ea102a80c38a3798242856e351623470aec76 Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 17 Aug 2020 17:13:12 +0200 Subject: [PATCH 1/4] Fixed size of subtitle translations submenu, so that it is wide enough to display every translation completely --- src/renderer/videoJS.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/videoJS.css b/src/renderer/videoJS.css index 3e7f106ea..89ee66323 100644 --- a/src/renderer/videoJS.css +++ b/src/renderer/videoJS.css @@ -1910,7 +1910,7 @@ video::-webkit-media-text-track-display { .video-js .vjs-menu-button-popup .vjs-menu .vjs-menu-content { background-color: transparent; - width: 5.5em; + width: 7.5em; left: 1.5em; padding-bottom: .5em; z-index: 1; From 91bcf52dab2e8ddb1c10841915cf87f6d0fe1c67 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 18 Aug 2020 20:32:01 +0200 Subject: [PATCH 2/4] Video publication string, Localization files Added: 1) video publication string - The code now creates a correctly translated string for the info on how far back the publication was 2) Localization files - Added the required template string as well as the unit for second and seconds to the yaml files to be able to utilize them in 1) --- .../components/ft-list-video/ft-list-video.js | 17 +++++- src/renderer/store/modules/utils.js | 58 +++++++++++++++++++ static/locales/de-DE.yaml | 10 +++- static/locales/en-US.yaml | 4 ++ 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index 219ae7b08..a707bdd0f 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -1,5 +1,6 @@ import Vue from 'vue' import FtIconButton from '../ft-icon-button/ft-icon-button.vue' +import { mapActions } from 'vuex' export default Vue.extend({ name: 'FtListVideo', @@ -213,7 +214,16 @@ export default Vue.extend({ this.viewCount = this.data.viewCount if (typeof (this.data.publishedText) !== 'undefined') { - this.uploadedTime = this.data.publishedText + // produces a string according to the template in the locales string + this.toLocaleStringS({ + publishText: this.data.publishedText, + templateString: this.$t('Video.Publicationtemplate'), + timeStrings: this.$t('Video.Published') + }).then((data) => { + this.uploadedTime = data + }).catch((error) => { + console.error(error) + }) } if (typeof (this.data.viewCount) !== 'undefined' && this.data.viewCount !== null) { @@ -265,6 +275,9 @@ export default Vue.extend({ } this.isLive = this.data.live - } + }, + ...mapActions([ + 'toLocaleStringS' + ]) } }) diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 6e0931f8f..b1776ee4a 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -166,6 +166,64 @@ const actions = { return vttString }, + toLocaleStringS ({ dispatch }, payload) { + const strings = payload.publishText.split(' ') + const singular = (strings[0] === '1') + let publicationString = payload.templateString.replace('$', strings[0]) + switch (strings[1].substring(0, 2)) { + case 'se': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Second) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Seconds) + } + break + case 'mi': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Minute) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Minutes) + } + break + case 'ho': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Hour) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Hours) + } + break + case 'da': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Day) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Days) + } + break + case 'we': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Week) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Weeks) + } + break + case 'mo': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Month) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Months) + } + break + case 'ye': + if (singular) { + publicationString = publicationString.replace('%', payload.timeStrings.Year) + } else { + publicationString = publicationString.replace('%', payload.timeStrings.Years) + } + break + } + return publicationString + }, + showToast (_, payload) { FtToastEvents.$emit('toast.open', payload.message, payload.action, payload.time) } diff --git a/static/locales/de-DE.yaml b/static/locales/de-DE.yaml index 1f1777923..5f4c7fe52 100644 --- a/static/locales/de-DE.yaml +++ b/static/locales/de-DE.yaml @@ -305,18 +305,22 @@ Video: Oct: Okt Nov: Nov Dec: Dez + Second: Sekunde + Seconds: Sekunden Hour: Stunde Hours: Stunden Day: Tag - Days: Tage + Days: Tagen Week: Woche Weeks: Wochen Month: Monat - Months: Monate + Months: Monaten Year: Jahr - Years: Jahre + Years: Jahren Ago: Vor Published on: Veröffentlicht am + Publicationtemplate: vor $ % veröffentlicht + #& Videos Videos: #& Sort By diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index b5ef87857..281f36b54 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -297,6 +297,8 @@ Video: Oct: Oct Nov: Nov Dec: Dec + Second: Second + Seconds: Seconds Hour: Hour Hours: Hours Day: Day @@ -309,6 +311,8 @@ Video: Years: Years Ago: Ago Published on: Published on + # $ is replaced with the number and % with the unit (days, hours, minutes...) + Publicationtemplate: $ % ago #& Videos Videos: #& Sort By From d4a3d35734f2768818f99c644dded4c7f99110f8 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 18 Aug 2020 21:37:43 +0200 Subject: [PATCH 3/4] Local API Publication Strings, Localization Files 2, Live and Upcoming videos Added: 1) Local API Publication Strings - When using the local API, the correctly translated strings stating how much time since publication has passed are displayed 2) Localization Files 2 - Added additional strings for upcoming videos as well as the missing strings to the third translation marked as missing Fixed: Live and Upcoming videos - Livestreams were not handled before but are now correctly implemented. Upcoming videos have a dummy string until the relevant data is provided by the scraper --- .../components/ft-list-video/ft-list-video.js | 23 ++++++++++++++++--- src/renderer/store/modules/utils.js | 8 ++++++- static/locales/de-DE.yaml | 1 + static/locales/en-US.yaml | 1 + static/locales/pt-PT.yaml | 9 ++++++++ 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index a707bdd0f..f9c59e37a 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -215,10 +215,14 @@ export default Vue.extend({ if (typeof (this.data.publishedText) !== 'undefined') { // produces a string according to the template in the locales string - this.toLocaleStringS({ + this.toLocalePublicationString({ publishText: this.data.publishedText, templateString: this.$t('Video.Publicationtemplate'), - timeStrings: this.$t('Video.Published') + timeStrings: this.$t('Video.Published'), + liveStreamString: this.$t('Video.Watching'), + upcomingString: this.$t('Video.Published.Upcoming'), + isLive: this.data.live, + isUpcoming: this.data.isUpcoming }).then((data) => { this.uploadedTime = data }).catch((error) => { @@ -262,6 +266,19 @@ export default Vue.extend({ } if (typeof (this.data.uploaded_at) !== 'undefined') { + this.toLocalePublicationString({ + publishText: this.data.uploaded_at, + templateString: this.$t('Video.Publicationtemplate'), + timeStrings: this.$t('Video.Published'), + liveStreamString: this.$t('Video.Watching'), + upcomingString: this.$t('Video.Published.Upcoming'), + isLive: this.data.live, + isUpcoming: false + }).then((data) => { + this.uploadedTime = data + }).catch((error) => { + console.error(error) + }) this.uploadedTime = this.data.uploaded_at } @@ -277,7 +294,7 @@ export default Vue.extend({ this.isLive = this.data.live }, ...mapActions([ - 'toLocaleStringS' + 'toLocalePublicationString' ]) } }) diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index b1776ee4a..bef9726bf 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -166,7 +166,13 @@ const actions = { return vttString }, - toLocaleStringS ({ dispatch }, payload) { + toLocalePublicationString ({ dispatch }, payload) { + if (payload.isLive) { + return '0' + payload.liveStreamString + } else if (payload.isUpcoming || payload.publishText === null) { + // the check for null is currently just an inferring of knowledge, because there is no other possibility left + return payload.upcomingString + } const strings = payload.publishText.split(' ') const singular = (strings[0] === '1') let publicationString = payload.templateString.replace('$', strings[0]) diff --git a/static/locales/de-DE.yaml b/static/locales/de-DE.yaml index 5f4c7fe52..50c917add 100644 --- a/static/locales/de-DE.yaml +++ b/static/locales/de-DE.yaml @@ -318,6 +318,7 @@ Video: Year: Jahr Years: Jahren Ago: Vor + Upcoming: Premiere bald Published on: Veröffentlicht am Publicationtemplate: vor $ % veröffentlicht diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 281f36b54..ad60dcc20 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -310,6 +310,7 @@ Video: Year: Year Years: Years Ago: Ago + Upcoming: Premieres soon Published on: Published on # $ is replaced with the number and % with the unit (days, hours, minutes...) Publicationtemplate: $ % ago diff --git a/static/locales/pt-PT.yaml b/static/locales/pt-PT.yaml index f25ad840d..4f2cbc132 100644 --- a/static/locales/pt-PT.yaml +++ b/static/locales/pt-PT.yaml @@ -302,6 +302,10 @@ Video: Oct: Out Nov: Nov Dec: Dez + # ! + Second: Second + # ! + Seconds: Seconds Hour: Hora Hours: Horas Day: Dia @@ -313,7 +317,12 @@ Video: Year: Ano Years: Anos Ago: Há + # ! + Upcoming: Premieres soon Published on: Publicado em + # ! + # $ is replaced with the number and % with the unit (days, hours, minutes...) + Publicationtemplate: $ % ago #& Videos Videos: #& Sort By From 3479442259116efb1873dcc5ffc1ce2bee81d11d Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 18 Aug 2020 21:42:32 +0200 Subject: [PATCH 4/4] For JetBrains IDEs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 95fa32466..5d78d0226 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ dist coverage __coverage__ csak-timelog.json +.idea/