fix(NcDateTime): Respect language

Signed-off-by: Christopher Ng <chrng8@gmail.com>
(cherry picked from commit 846ebeaafb)
This commit is contained in:
Christopher Ng 2024-04-22 16:48:04 -07:00
Родитель cbcd764b53
Коммит 15f3d9b288
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -21,7 +21,7 @@
*/
import type { MaybeRef } from 'vue'
import { getCanonicalLocale } from '@nextcloud/l10n'
import { getCanonicalLocale, getLanguage } from '@nextcloud/l10n'
import { computed, onUnmounted, ref, toValue, watchEffect } from 'vue'
import { t } from '../l10n.js'
@ -47,7 +47,7 @@ interface FormatDateOptions {
}
/**
* Composable for formatting time stamps using current users locale
* Composable for formatting time stamps using current users locale and language
*
* @param {import('vue').MaybeRef<Date | number>} timestamp Current timestamp
* @param {object} opts Optional options
@ -86,7 +86,7 @@ export function useFormatDateTime(
/** Time string formatted for main text */
const formattedTime = computed<string>(() => {
if (wrappedOptions.value.relativeTime !== false) {
const formatter = new Intl.RelativeTimeFormat(getCanonicalLocale(), { numeric: 'auto', style: wrappedOptions.value.relativeTime })
const formatter = new Intl.RelativeTimeFormat(getLanguage(), { numeric: 'auto', style: wrappedOptions.value.relativeTime })
const diff = date.value.getTime() - currentTime.value
const seconds = diff / 1000