mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 09:59:58 +01:00
refactor: 💡 formatter format/manual options logic
This commit is contained in:
parent
850fd09f32
commit
9d636694b1
@ -42,12 +42,9 @@ export const getDateFormatter: MemoizedIntlFormatter<
|
||||
throw new Error('[svelte-i18n] A "locale" must be set to format dates')
|
||||
}
|
||||
|
||||
const hasInlineArgs = Object.keys(options).length > 0
|
||||
if (!hasInlineArgs) {
|
||||
options =
|
||||
typeof format === 'string'
|
||||
? getIntlFormatterOptions('date', format)
|
||||
: getIntlFormatterOptions('date', 'short')
|
||||
if (format) options = getIntlFormatterOptions('date', format)
|
||||
else if (Object.keys(options).length === 0) {
|
||||
options = getIntlFormatterOptions('date', 'short')
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat(locale, options)
|
||||
@ -64,12 +61,9 @@ export const getTimeFormatter: MemoizedIntlFormatter<
|
||||
)
|
||||
}
|
||||
|
||||
const hasInlineArgs = Object.keys(options).length > 0
|
||||
if (!hasInlineArgs) {
|
||||
options =
|
||||
typeof format === 'string'
|
||||
? getIntlFormatterOptions('time', format)
|
||||
: getIntlFormatterOptions('time', 'short')
|
||||
if (format) options = getIntlFormatterOptions('time', format)
|
||||
else if (Object.keys(options).length === 0) {
|
||||
options = getIntlFormatterOptions('time', 'short')
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat(locale, options)
|
||||
|
@ -5,7 +5,7 @@ export function defineMessages(i: Record<string, MessageObject>) {
|
||||
return i
|
||||
}
|
||||
|
||||
export { configure } from './configs'
|
||||
export { init } from './configs'
|
||||
export { $locale as locale } from './stores/locale'
|
||||
export {
|
||||
$dictionary as dictionary,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
import { lookupMessage } from '../../../src/client/includes/lookup'
|
||||
|
||||
|
||||
import {
|
||||
isFallbackLocaleOf,
|
||||
getFallbackOf,
|
||||
|
Loading…
Reference in New Issue
Block a user