fix(NcDateTime): Respect language
Signed-off-by: Christopher Ng <chrng8@gmail.com>
(cherry picked from commit 846ebeaafb
)
This commit is contained in:
Родитель
cbcd764b53
Коммит
15f3d9b288
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { MaybeRef } from 'vue'
|
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 { computed, onUnmounted, ref, toValue, watchEffect } from 'vue'
|
||||||
import { t } from '../l10n.js'
|
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 {import('vue').MaybeRef<Date | number>} timestamp Current timestamp
|
||||||
* @param {object} opts Optional options
|
* @param {object} opts Optional options
|
||||||
|
@ -86,7 +86,7 @@ export function useFormatDateTime(
|
||||||
/** Time string formatted for main text */
|
/** Time string formatted for main text */
|
||||||
const formattedTime = computed<string>(() => {
|
const formattedTime = computed<string>(() => {
|
||||||
if (wrappedOptions.value.relativeTime !== false) {
|
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 diff = date.value.getTime() - currentTime.value
|
||||||
const seconds = diff / 1000
|
const seconds = diff / 1000
|
||||||
|
|
Загрузка…
Ссылка в новой задаче