mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
chore: 🤖 oops, fix actual build-time types being git ignored
This commit is contained in:
parent
73c80e9bea
commit
bb6dd01558
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,4 +2,4 @@ node_modules
|
||||||
*.log
|
*.log
|
||||||
dist/
|
dist/
|
||||||
coverage/
|
coverage/
|
||||||
types/
|
/types/
|
|
@ -1,6 +1,6 @@
|
||||||
import { writable, derived } from 'svelte/store'
|
import { writable, derived } from 'svelte/store'
|
||||||
|
|
||||||
import { LocaleDictionary, DeepDictionary, Dictionary } from '../types/index'
|
import { LocaleDictionary, DeepDictionary, Dictionary } from '../types'
|
||||||
import { flatObj } from '../includes/utils'
|
import { flatObj } from '../includes/utils'
|
||||||
|
|
||||||
import { getFallbackOf } from './locale'
|
import { getFallbackOf } from './locale'
|
||||||
|
|
63
src/runtime/types/index.ts
Normal file
63
src/runtime/types/index.ts
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
import { Formats } from 'intl-messageformat'
|
||||||
|
|
||||||
|
export interface DeepDictionary {
|
||||||
|
[key: string]: DeepDictionary | string | string[]
|
||||||
|
}
|
||||||
|
export type LocaleDictionary = Record<string, string>
|
||||||
|
export type Dictionary = Record<string, LocaleDictionary>
|
||||||
|
|
||||||
|
export interface MessageObject {
|
||||||
|
id?: string
|
||||||
|
locale?: string
|
||||||
|
format?: string
|
||||||
|
default?: string
|
||||||
|
values?: Record<string, string | number | Date>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type MessageFormatter = (
|
||||||
|
id: string | MessageObject,
|
||||||
|
options?: MessageObject
|
||||||
|
) => string
|
||||||
|
|
||||||
|
export type TimeFormatter = (
|
||||||
|
d: Date | number,
|
||||||
|
options?: IntlFormatterOptions<Intl.DateTimeFormatOptions>
|
||||||
|
) => string
|
||||||
|
|
||||||
|
export type DateFormatter = (
|
||||||
|
d: Date | number,
|
||||||
|
options?: IntlFormatterOptions<Intl.DateTimeFormatOptions>
|
||||||
|
) => string
|
||||||
|
|
||||||
|
export type NumberFormatter = (
|
||||||
|
d: number,
|
||||||
|
options?: IntlFormatterOptions<Intl.NumberFormatOptions>
|
||||||
|
) => string
|
||||||
|
|
||||||
|
type IntlFormatterOptions<T> = T & {
|
||||||
|
format?: string
|
||||||
|
locale?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MemoizedIntlFormatter<T, U> {
|
||||||
|
(options?: IntlFormatterOptions<U>): T
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MessagesLoader {
|
||||||
|
(): Promise<any>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetClientLocaleOptions {
|
||||||
|
navigator?: boolean
|
||||||
|
hash?: string
|
||||||
|
search?: string
|
||||||
|
pathname?: RegExp
|
||||||
|
hostname?: RegExp
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigureOptions {
|
||||||
|
fallbackLocale: string
|
||||||
|
initialLocale?: string | GetClientLocaleOptions
|
||||||
|
formats?: Partial<Formats>
|
||||||
|
loadingDelay?: number
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { Formatter } from '../../../src/runtime/types/index'
|
import { Formatter } from '../../../src/runtime/types'
|
||||||
import { $format } from '../../../src/runtime/stores/format'
|
import { $format } from '../../../src/runtime/stores/format'
|
||||||
import { init } from '../../../src/runtime/configs'
|
import { init } from '../../../src/runtime/configs'
|
||||||
import { addMessages } from '../../../src/runtime/stores/dictionary'
|
import { addMessages } from '../../../src/runtime/stores/dictionary'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user