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
This commit is contained in:
Airidasz 2021-10-02 18:43:42 +03:00 committed by GitHub
parent 8a3515df16
commit 0a12e58796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -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() {

View File

@ -288,7 +288,9 @@ const actions = {
break
}
}
const locale = settings.currentLocale.replace('-', '_')
ytpl(playlistId, {
hl: locale,
limit: 'Infinity',
requestOptions: { agent }
}).then((result) => {