2019-11-20 05:32:30 +01:00
|
|
|
import merge from 'deepmerge'
|
2019-11-19 17:18:42 +01:00
|
|
|
|
2019-11-22 02:11:31 +01:00
|
|
|
import { GetClientLocaleOptions, MessageObject } from './types'
|
|
|
|
import { getClientLocale } from './includes/utils'
|
|
|
|
import { $locale } from './stores/locale'
|
2019-11-19 17:18:42 +01:00
|
|
|
|
|
|
|
// defineMessages allow us to define and extract dynamic message ids
|
2019-11-22 02:11:31 +01:00
|
|
|
export function defineMessages(i: Record<string, MessageObject>) {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
export function waitInitialLocale(options: GetClientLocaleOptions | string) {
|
|
|
|
if (typeof options === 'string') {
|
|
|
|
return $locale.set(options)
|
|
|
|
}
|
|
|
|
return $locale.set(getClientLocale(options))
|
|
|
|
}
|
2019-11-19 17:18:42 +01:00
|
|
|
|
2019-11-20 20:31:55 +01:00
|
|
|
export { $locale as locale, loadLocale as preloadLocale } from './stores/locale'
|
2019-11-19 17:18:42 +01:00
|
|
|
export {
|
2019-11-19 21:12:15 +01:00
|
|
|
$dictionary as dictionary,
|
2019-11-20 05:32:30 +01:00
|
|
|
$locales as locales,
|
2019-11-22 02:12:56 +01:00
|
|
|
addMessages,
|
2019-11-20 20:31:55 +01:00
|
|
|
} from './stores/dictionary'
|
2019-11-22 02:11:31 +01:00
|
|
|
export { $isLoading as isLoading } from './stores/loading'
|
2019-11-20 20:31:55 +01:00
|
|
|
export { $format as format, $format as _, $format as t } from './stores/format'
|
|
|
|
|
|
|
|
// utilities
|
2019-11-22 02:11:31 +01:00
|
|
|
export { getClientLocale, merge }
|
2019-11-20 20:31:55 +01:00
|
|
|
export { customFormats, addCustomFormats } from './includes/formats'
|
|
|
|
export {
|
|
|
|
flushQueue as waitLocale,
|
2019-11-20 06:05:34 +01:00
|
|
|
registerLocaleLoader as register,
|
2019-11-20 20:31:55 +01:00
|
|
|
} from './includes/loaderQueue'
|