diff --git a/.eslintignore b/.eslintignore index f98ec03..a9f13f8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,2 @@ /test/fixtures -dist \ No newline at end of file +dist/ \ No newline at end of file diff --git a/README.md b/README.md index 52979a3..32077bd 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ > 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) + +### Requirements + +Node: `>= 11.15.0` + +Browsers: `Chrome 38+`, `Edge 12+`, `Firefox 13+`, `Opera 25+`, `Safari 8+`. diff --git a/src/client/includes/loaderQueue.ts b/src/client/includes/loaderQueue.ts index 7cd16d5..2a5c360 100644 --- a/src/client/includes/loaderQueue.ts +++ b/src/client/includes/loaderQueue.ts @@ -1,6 +1,4 @@ -import merge from 'deepmerge' - -import { LocaleLoader } from '../types' +import { MessagesLoader } from '../types' import { hasLocaleDictionary, $dictionary, @@ -12,7 +10,7 @@ import { $loading } from '../stores/loading' import { removeFromLookupCache } from './lookup' import { getLocalesFrom } from './utils' -const loaderQueue: Record> = {} +const loaderQueue: Record> = {} function createLocaleQueue(locale: string) { loaderQueue[locale] = new Set() @@ -44,7 +42,7 @@ export function hasLocaleQueue(locale: string) { .some(getLocaleQueue) } -export function addLoaderToQueue(locale: string, loader: LocaleLoader) { +export function addLoaderToQueue(locale: string, loader: MessagesLoader) { 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) const queue = getLocaleQueue(locale) diff --git a/src/client/stores/dictionary.ts b/src/client/stores/dictionary.ts index a00bdab..0a62393 100644 --- a/src/client/stores/dictionary.ts +++ b/src/client/stores/dictionary.ts @@ -1,6 +1,7 @@ -import { LocaleDictionary } from './../types/index' -import { writable, derived } from 'svelte/store' import merge from 'deepmerge' +import { writable, derived } from 'svelte/store' + +import { LocaleDictionary } from '../types/index' let dictionary: LocaleDictionary diff --git a/src/client/types/index.ts b/src/client/types/index.ts index 7fccda3..64af49c 100644 --- a/src/client/types/index.ts +++ b/src/client/types/index.ts @@ -42,6 +42,6 @@ export interface Formatter extends FormatterFn { lower: FormatterFn } -export interface LocaleLoader { +export interface MessagesLoader { (): Promise }