diff --git a/src/client/configs.ts b/src/client/configs.ts index f7a7a66..fdab4ba 100644 --- a/src/client/configs.ts +++ b/src/client/configs.ts @@ -59,7 +59,7 @@ export function getOptions() { return options } -export function configure(opts: ConfigureOptions) { +export function init(opts: ConfigureOptions) { const fallbackLocale = (options.fallbackLocale = opts.fallbackLocale) const initialLocale = opts.initialLocale diff --git a/test/client/configs.test.ts b/test/client/configs.test.ts index 20063b3..0915e6e 100644 --- a/test/client/configs.test.ts +++ b/test/client/configs.test.ts @@ -1,7 +1,7 @@ import { get } from 'svelte/store' import { - configure, + init, getOptions, defaultOptions, defaultFormats, @@ -9,19 +9,19 @@ import { import { $locale } from '../../src/client/stores/locale' beforeEach(() => { - configure(defaultOptions) + init(defaultOptions) }) -test('configures the fallback locale', () => { +test('inits the fallback locale', () => { expect(getOptions().fallbackLocale).toBe(null) - configure({ + init({ fallbackLocale: 'en', }) expect(getOptions().fallbackLocale).toBe('en') }) -test('configures the initial locale by string', () => { - configure({ +test('inits the initial locale by string', () => { + init({ fallbackLocale: 'pt', initialLocale: 'en', }) @@ -29,7 +29,7 @@ test('configures the initial locale by string', () => { expect(get($locale)).toBe('en') }) -test('configures the initial locale by client heuristics', () => { +test('inits the initial locale by client heuristics', () => { delete window.location window.location = { search: '?lang=en-US&foo', @@ -38,7 +38,7 @@ test('configures the initial locale by client heuristics', () => { hash: '', } as any - configure({ + init({ fallbackLocale: 'pt', initialLocale: { search: 'lang', @@ -51,7 +51,7 @@ test('configures the initial locale by client heuristics', () => { test('adds custom formats for time, date and number values', () => { const customFormats = require('../fixtures/formats.json') - configure({ + init({ fallbackLocale: 'en', formats: customFormats, }) @@ -60,6 +60,6 @@ test('adds custom formats for time, date and number values', () => { }) test('sets the minimum delay to set the loading store value', () => { - configure({ fallbackLocale: 'en', loadingDelay: 300 }) + init({ fallbackLocale: 'en', loadingDelay: 300 }) expect(getOptions().loadingDelay).toBe(300) }) diff --git a/test/client/stores/locale.test.ts b/test/client/stores/locale.test.ts index ab9f635..953ba9f 100644 --- a/test/client/stores/locale.test.ts +++ b/test/client/stores/locale.test.ts @@ -9,17 +9,17 @@ import { $locale, isRelatedLocale, } from '../../../src/client/stores/locale' -import { getOptions, configure } from '../../../src/client/configs' +import { getOptions, init } from '../../../src/client/configs' import { register } from '../../../src/client' import { hasLocaleQueue } from '../../../src/client/includes/loaderQueue' beforeEach(() => { - configure({ fallbackLocale: undefined }) + init({ fallbackLocale: undefined }) $locale.set(undefined) }) test('sets and gets the fallback locale', () => { - configure({ fallbackLocale: 'en' }) + init({ fallbackLocale: 'en' }) expect(getOptions().fallbackLocale).toBe('en') }) @@ -44,17 +44,17 @@ test('gets the next fallback locale of a locale', () => { }) test('gets the global fallback locale if set', () => { - configure({ fallbackLocale: 'en' }) + init({ fallbackLocale: 'en' }) expect(getFallbackOf('it')).toBe('en') }) test('should not get the global fallback as the fallback of itself', () => { - configure({ fallbackLocale: 'en' }) + init({ fallbackLocale: 'en' }) expect(getFallbackOf('en')).toBe(null) }) test('if global fallback locale has a fallback, it should return it', () => { - configure({ fallbackLocale: 'en-US' }) + init({ fallbackLocale: 'en-US' }) expect(getFallbackOf('en-US')).toBe('en') }) @@ -69,7 +69,7 @@ test('gets all fallback locales of a locale', () => { }) test('gets all fallback locales of a locale including the global fallback locale', () => { - configure({ fallbackLocale: 'pt' }) + init({ fallbackLocale: 'pt' }) expect(getRelatedLocalesOf('en-US')).toEqual(['en', 'en-US', 'pt']) expect(getRelatedLocalesOf('en-US')).toEqual(['en', 'en-US', 'pt']) expect(getRelatedLocalesOf('az-Cyrl-AZ')).toEqual([ @@ -80,7 +80,7 @@ test('gets all fallback locales of a locale including the global fallback locale ]) }) test('gets all fallback locales of a locale including the global fallback locale and its fallbacks', () => { - configure({ fallbackLocale: 'pt-BR' }) + init({ fallbackLocale: 'pt-BR' }) expect(getRelatedLocalesOf('en-US')).toEqual(['en', 'en-US', 'pt', 'pt-BR']) expect(getRelatedLocalesOf('en-US')).toEqual(['en', 'en-US', 'pt', 'pt-BR']) expect(getRelatedLocalesOf('az-Cyrl-AZ')).toEqual([ @@ -93,7 +93,7 @@ test('gets all fallback locales of a locale including the global fallback locale }) test("don't list fallback locale twice", () => { - configure({ fallbackLocale: 'pt-BR' }) + init({ fallbackLocale: 'pt-BR' }) expect(getRelatedLocalesOf('pt-BR')).toEqual(['pt', 'pt-BR']) expect(getRelatedLocalesOf('pt')).toEqual(['pt']) }) @@ -105,13 +105,13 @@ test('gets the current locale', () => { }) test('if no initial locale is set, set the locale to the fallback', () => { - configure({ fallbackLocale: 'pt' }) + init({ fallbackLocale: 'pt' }) expect(get($locale)).toBe('pt') expect(getOptions().fallbackLocale).toBe('pt') }) test('if no initial locale was found, set to the fallback locale', () => { - configure({ + init({ fallbackLocale: 'en', initialLocale: { hash: 'lang',