mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
style: 💄 fix eslint errors
This commit is contained in:
parent
3423207c02
commit
c9eb746797
|
@ -1,2 +1,2 @@
|
||||||
/test/fixtures
|
/test/fixtures
|
||||||
dist
|
dist/
|
|
@ -4,6 +4,12 @@
|
||||||
|
|
||||||
> Internationalization for Svelte.
|
> Internationalization for Svelte.
|
||||||
|
|
||||||
`svelte-i18n` uses `stores` to keep track of the current locale, dictionary of messages and the main format function. This way, we keep everything neat, in sync and easy to use on your svelte files.
|
`svelte-i18n` utilizes [Svelte stores](https://svelte.dev/docs#svelte_store) to keep track of the current `locale`, `dictionary` of messages and to `format` messages. This way, we keep everything neat, in sync and easy to use on your svelte files.
|
||||||
|
|
||||||
### [Go to documentation](https://github.com/kaisermann/svelte-i18n/wiki)
|
### [Go to documentation](https://github.com/kaisermann/svelte-i18n/wiki)
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
Node: `>= 11.15.0`
|
||||||
|
|
||||||
|
Browsers: `Chrome 38+`, `Edge 12+`, `Firefox 13+`, `Opera 25+`, `Safari 8+`.
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import merge from 'deepmerge'
|
import { MessagesLoader } from '../types'
|
||||||
|
|
||||||
import { LocaleLoader } from '../types'
|
|
||||||
import {
|
import {
|
||||||
hasLocaleDictionary,
|
hasLocaleDictionary,
|
||||||
$dictionary,
|
$dictionary,
|
||||||
|
@ -12,7 +10,7 @@ import { $loading } from '../stores/loading'
|
||||||
import { removeFromLookupCache } from './lookup'
|
import { removeFromLookupCache } from './lookup'
|
||||||
import { getLocalesFrom } from './utils'
|
import { getLocalesFrom } from './utils'
|
||||||
|
|
||||||
const loaderQueue: Record<string, Set<LocaleLoader>> = {}
|
const loaderQueue: Record<string, Set<MessagesLoader>> = {}
|
||||||
|
|
||||||
function createLocaleQueue(locale: string) {
|
function createLocaleQueue(locale: string) {
|
||||||
loaderQueue[locale] = new Set()
|
loaderQueue[locale] = new Set()
|
||||||
|
@ -44,7 +42,7 @@ export function hasLocaleQueue(locale: string) {
|
||||||
.some(getLocaleQueue)
|
.some(getLocaleQueue)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addLoaderToQueue(locale: string, loader: LocaleLoader) {
|
export function addLoaderToQueue(locale: string, loader: MessagesLoader) {
|
||||||
loaderQueue[locale].add(loader)
|
loaderQueue[locale].add(loader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +70,7 @@ export async function flushQueue(locale: string = getCurrentLocale()) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerLocaleLoader(locale: string, loader: LocaleLoader) {
|
export function registerLocaleLoader(locale: string, loader: MessagesLoader) {
|
||||||
if (!getLocaleQueue(locale)) createLocaleQueue(locale)
|
if (!getLocaleQueue(locale)) createLocaleQueue(locale)
|
||||||
|
|
||||||
const queue = getLocaleQueue(locale)
|
const queue = getLocaleQueue(locale)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { LocaleDictionary } from './../types/index'
|
|
||||||
import { writable, derived } from 'svelte/store'
|
|
||||||
import merge from 'deepmerge'
|
import merge from 'deepmerge'
|
||||||
|
import { writable, derived } from 'svelte/store'
|
||||||
|
|
||||||
|
import { LocaleDictionary } from '../types/index'
|
||||||
|
|
||||||
let dictionary: LocaleDictionary
|
let dictionary: LocaleDictionary
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,6 @@ export interface Formatter extends FormatterFn {
|
||||||
lower: FormatterFn
|
lower: FormatterFn
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LocaleLoader {
|
export interface MessagesLoader {
|
||||||
(): Promise<any>
|
(): Promise<any>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user