Merge branch 'master' of github.com:kaisermann/svelte-i18n

This commit is contained in:
Christian Kaisermann 2018-08-14 15:21:32 -03:00
commit 38dcecb724
2 changed files with 8 additions and 7 deletions

View File

@ -7,7 +7,7 @@ export { capital, title, upper, lower }
export function i18n(store, { dictionary: initialDictionary }) {
const formatter = new Formatter()
let dictionary = {}
let dictionary
let currentLocale
const getLocalizedMessage = (
@ -94,7 +94,11 @@ export function i18n(store, { dictionary: initialDictionary }) {
},
}
store.i18n.extendDictionary(initialDictionary)
if (Array.isArray(initialDictionary)) {
dictionary = deepmerge.all(initialDictionary)
} else {
initialDictionary = dictionary
}
return store
}

View File

@ -4,7 +4,7 @@ import { i18n } from '../src/index'
import { Store } from 'svelte/store.umd'
import { capital, title, upper, lower, isObject } from '../src/utils'
const store = new Store()
let store = new Store()
const locales = {
'pt-br': {
test: 'teste',
@ -30,11 +30,8 @@ const locales = {
},
}
i18n(store, { dictionary: locales })
i18n(store, { dictionary: [locales] })
/**
* Dummy test
*/
describe('Utilities', () => {
it('should check if a variable is an object', () => {
expect(isObject({})).toBe(true)