Skip to content
Open
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion src/client/theme-default/components/VPDocFooterLastUpdated.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,27 @@ const datetime = ref('')
// set time on mounted hook to avoid hydration mismatch due to
// potential differences in timezones of the server and clients
onMounted(() => {
function findBestLocaleMatch(pageLocale: string): string | undefined {
return navigator.languages.find((userLang) => {
if (pageLocale === userLang)
return pageLocale
Comment thread
brc-dd marked this conversation as resolved.
Outdated

// Edge browser: case for ca-valencia
if (pageLocale === 'ca-valencia' && userLang === 'ca-Es-VALENCIA')
return pageLocale

// add iso-639 support for Latin America
if (userLang.startsWith('es-') && userLang !== 'es-ES' && pageLocale === 'es-419')
return pageLocale

return userLang.startsWith(pageLocale) ? pageLocale : undefined
})
}
watchEffect(() => {
datetime.value = new Intl.DateTimeFormat(
theme.value.lastUpdated?.formatOptions?.forceLocale ? lang.value : undefined,
theme.value.lastUpdated?.formatOptions?.forceLocale
? lang.value
: findBestLocaleMatch(lang.value),
theme.value.lastUpdated?.formatOptions ?? {
dateStyle: 'short',
timeStyle: 'short'
Expand Down