Format playlist dates with the selected locale (#2244)

* Format Invidious playlist dates with the selected locale

* Fix language for locale API as well

* Add special handling for Norsk nynorsk

* Workaround system locale issue
This commit is contained in:
absidue 2022-05-31 03:43:21 +02:00 committed by GitHub
parent dd5c68223b
commit 365b8f81ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 11 deletions

View File

@ -59,7 +59,6 @@
"@silvermine/videojs-quality-selector": "^1.2.5",
"autolinker": "^3.15.0",
"bulma-pro": "^0.2.0",
"dateformat": "^4.5.1",
"electron-context-menu": "^3.1.2",
"http-proxy-agent": "^4.0.1",
"https-proxy-agent": "^5.0.0",

View File

@ -7,6 +7,8 @@ import { SocksProxyAgent } from 'socks-proxy-agent'
import { HttpsProxyAgent } from 'https-proxy-agent'
import { HttpProxyAgent } from 'http-proxy-agent'
import i18n from '../../i18n/index'
const state = {
isYtSearchRunning: false
}
@ -288,10 +290,15 @@ const actions = {
break
}
}
const locale = settings.currentLocale.replace('-', '_')
let locale = i18n.locale.replace('_', '-')
if (locale === 'nn') {
locale = 'no'
}
ytpl(playlistId, {
hl: locale,
limit: 'Infinity',
limit: Infinity,
requestOptions: { agent }
}).then((result) => {
resolve(result)

View File

@ -1,11 +1,11 @@
import Vue from 'vue'
import { mapActions } from 'vuex'
import dateFormat from 'dateformat'
import FtLoader from '../../components/ft-loader/ft-loader.vue'
import FtCard from '../../components/ft-card/ft-card.vue'
import PlaylistInfo from '../../components/playlist-info/playlist-info.vue'
import FtListVideo from '../../components/ft-list-video/ft-list-video.vue'
import FtFlexBox from '../../components/ft-flex-box/ft-flex-box.vue'
import i18n from '../../i18n/index'
export default Vue.extend({
name: 'Playlist',
@ -36,6 +36,9 @@ export default Vue.extend({
},
currentInvidiousInstance: function () {
return this.$store.getters.getCurrentInvidiousInstance
},
currentLocale: function () {
return i18n.locale.replace('_', '-')
}
},
watch: {
@ -134,8 +137,7 @@ export default Vue.extend({
}
const dateString = new Date(result.updated * 1000)
dateString.setDate(dateString.getDate() + 1)
this.infoData.lastUpdated = dateFormat(dateString, 'mmm dS, yyyy')
this.infoData.lastUpdated = dateString.toLocaleDateString(this.currentLocale, { year: 'numeric', month: 'short', day: 'numeric' })
this.playlistItems = this.playlistItems.concat(result.videos)

View File

@ -3177,11 +3177,6 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
dateformat@^4.5.1:
version "4.6.3"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.6.3.tgz#556fa6497e5217fedb78821424f8a1c22fa3f4b5"
integrity sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==
de-indent@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"