From 56a7d9aa74bbb1d945c6ca3a3573b5e49ba3ca65 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 21 Mar 2023 18:04:27 +0530 Subject: [PATCH] fix(theme): use locale lang instead of navigator lang for last updated (#2118) --- .../theme-default/components/VPDocFooterLastUpdated.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/theme-default/components/VPDocFooterLastUpdated.vue b/src/client/theme-default/components/VPDocFooterLastUpdated.vue index 38cfa3a39ef..6fef75cde52 100644 --- a/src/client/theme-default/components/VPDocFooterLastUpdated.vue +++ b/src/client/theme-default/components/VPDocFooterLastUpdated.vue @@ -2,18 +2,17 @@ import { ref, computed, watchEffect, onMounted } from 'vue' import { useData } from '../composables/data' -const { theme, page } = useData() +const { theme, page, lang } = useData() const date = computed(() => new Date(page.value.lastUpdated!)) const isoDatetime = computed(() => date.value.toISOString()) const datetime = ref('') -// set time on mounted hook because the locale string might be different -// based on end user and will lead to potential hydration mismatch if -// calculated at build time +// set time on mounted hook to avoid hydration mismatch due to +// potential differences in timezones of the server and clients onMounted(() => { watchEffect(() => { - datetime.value = date.value.toLocaleString(window.navigator.language) + datetime.value = date.value.toLocaleString(lang.value) }) })