From 0a12e587968b4213b2fe5e089e70e504a4525117 Mon Sep 17 00:00:00 2001 From: Airidasz <61290246+Airidasz@users.noreply.github.com> Date: Sat, 2 Oct 2021 18:43:42 +0300 Subject: [PATCH] Date locale change (#1757) * Update watch-video-info.js * Modified language files Modified language files to include the ISO 639-1 language code * Change date based on locale This changes the date based on locale. If locale does not exist it defaults to English * Removed locale codes from files * Getting locale code from $store * Delete launch.json * Replace _ with - for locale * Add locale change to playlist query Change the locale of playlist query. On error defaults to user location (the library does it, no extra work required) Does not work with Norsk nyorsk locale * Make linter happy * Lint * replace dashes with underscores for locale string --- .../components/watch-video-info/watch-video-info.js | 10 +++++++--- src/renderer/store/modules/ytdl.js | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js index 918d901e..30579e88 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -130,6 +130,10 @@ export default Vue.extend({ return this.$store.getters.getCurrentInvidiousInstance }, + currentLocale: function () { + return this.$store.getters.getCurrentLocale + }, + profileList: function () { return this.$store.getters.getProfileList }, @@ -227,9 +231,9 @@ export default Vue.extend({ dateString() { const date = new Date(this.published) - const dateSplit = date.toDateString().split(' ') - const localeDateString = `Video.Published.${dateSplit[1]}` - return `${this.$t(localeDateString)} ${dateSplit[2]}, ${dateSplit[3]}` + const locale = this.currentLocale.replace('_', '-') + const localeDateString = new Intl.DateTimeFormat([locale, 'en'], { dateStyle: 'medium' }).format(date) + return `${localeDateString}` }, publishedString() { diff --git a/src/renderer/store/modules/ytdl.js b/src/renderer/store/modules/ytdl.js index f3addc75..db8895db 100644 --- a/src/renderer/store/modules/ytdl.js +++ b/src/renderer/store/modules/ytdl.js @@ -288,7 +288,9 @@ const actions = { break } } + const locale = settings.currentLocale.replace('-', '_') ytpl(playlistId, { + hl: locale, limit: 'Infinity', requestOptions: { agent } }).then((result) => {