aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-12-03 00:17:55 +0300
committerrinpatch <rinpatch@sdf.org>2021-01-21 20:31:54 +0300
commit60a8a89f5b7526af44c9682e151dd92c979b1412 (patch)
tree14ba6b8aa42c5ca2a4d2ab6e81e5930e587fdb98 /src
parent0358284ebf2accf6e0a20ec04e0448437827fadc (diff)
Use app locale with toLocaleString/toLocaleDateString
Fixes inconsistent date formatting when browser language is different from PleromaFE language.
Diffstat (limited to 'src')
-rw-r--r--src/components/chat_message_date/chat_message_date.vue4
-rw-r--r--src/components/settings_modal/tabs/security_tab/security_tab.js3
-rw-r--r--src/components/timeago/timeago.vue6
3 files changed, 9 insertions, 4 deletions
diff --git a/src/components/chat_message_date/chat_message_date.vue b/src/components/chat_message_date/chat_message_date.vue
index 79c346b6..98349b75 100644
--- a/src/components/chat_message_date/chat_message_date.vue
+++ b/src/components/chat_message_date/chat_message_date.vue
@@ -5,6 +5,8 @@
</template>
<script>
+import localeService from 'src/services/locale/locale.service.js'
+
export default {
name: 'Timeago',
props: ['date'],
@@ -16,7 +18,7 @@ export default {
if (this.date.getTime() === today.getTime()) {
return this.$t('display_date.today')
} else {
- return this.date.toLocaleDateString('en', { day: 'numeric', month: 'long' })
+ return this.date.toLocaleDateString(localeService.internalToBrowserLocale(this.$i18n.locale), { day: 'numeric', month: 'long' })
}
}
}
diff --git a/src/components/settings_modal/tabs/security_tab/security_tab.js b/src/components/settings_modal/tabs/security_tab/security_tab.js
index 811161a5..65d20fc0 100644
--- a/src/components/settings_modal/tabs/security_tab/security_tab.js
+++ b/src/components/settings_modal/tabs/security_tab/security_tab.js
@@ -1,6 +1,7 @@
import ProgressButton from 'src/components/progress_button/progress_button.vue'
import Checkbox from 'src/components/checkbox/checkbox.vue'
import Mfa from './mfa.vue'
+import localeService from 'src/services/locale/locale.service.js'
const SecurityTab = {
data () {
@@ -37,7 +38,7 @@ const SecurityTab = {
return {
id: oauthToken.id,
appName: oauthToken.app_name,
- validUntil: new Date(oauthToken.valid_until).toLocaleDateString()
+ validUntil: new Date(oauthToken.valid_until).toLocaleDateString(localeService.internalToBrowserLocale(this.$i18n.locale))
}
})
}
diff --git a/src/components/timeago/timeago.vue b/src/components/timeago/timeago.vue
index 6df0524d..55a2dd94 100644
--- a/src/components/timeago/timeago.vue
+++ b/src/components/timeago/timeago.vue
@@ -9,6 +9,7 @@
<script>
import * as DateUtils from 'src/services/date_utils/date_utils.js'
+import localeService from 'src/services/locale/locale.service.js'
export default {
name: 'Timeago',
@@ -21,9 +22,10 @@ export default {
},
computed: {
localeDateString () {
+ const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
return typeof this.time === 'string'
- ? new Date(Date.parse(this.time)).toLocaleString()
- : this.time.toLocaleString()
+ ? new Date(Date.parse(this.time)).toLocaleString(browserLocale)
+ : this.time.toLocaleString(browserLocale)
}
},
created () {