Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Set current language for formatted dates #1806

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/bugfix-language-formatted-dates
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Set language for date formatting

We're now setting the language when formatting dates, so that localized parts of the date/time get shown according to the respective language.

https://github.com/owncloud/owncloud-design-system/pull/1806
12 changes: 9 additions & 3 deletions src/components/templates/OcTableFiles/OcTableFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ export default {
contextMenuLabel() {
return this.$gettext("Show context menu")
},

currentLanguage() {
return (this.$language?.current || "").split("_")[0]
},
},
methods: {
fileDragged(file) {
Expand Down Expand Up @@ -506,13 +510,15 @@ export default {
this.emitSelect([resource])
},
formatDate(date) {
return DateTime.fromJSDate(new Date(date)).toLocaleString(DateTime.DATETIME_FULL)
return DateTime.fromJSDate(new Date(date))
.setLocale(this.currentLanguage)
.toLocaleString(DateTime.DATETIME_FULL)
},
formatDateRelative(date) {
return DateTime.fromJSDate(new Date(date)).toRelative()
return DateTime.fromJSDate(new Date(date)).setLocale(this.currentLanguage).toRelative()
},
unixDate(date) {
return DateTime.fromJSDate(new Date(date)).valueOf()
return DateTime.fromJSDate(new Date(date)).setLocale(this.currentLanguage).valueOf()
},

emitSelect(resources) {
Expand Down