mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 18:10:43 +01:00
Accept array of dictionaries
This commit is contained in:
parent
5662f0401c
commit
0bb40b9f34
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "svelte-i18n",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "svelte-i18n",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"license": "MIT",
|
||||
"main": "dist/i18n.js",
|
||||
"module": "dist/i18n.m.js",
|
||||
|
@ -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 = (
|
||||
@ -83,7 +83,11 @@ export function i18n(store, { dictionary: initialDictionary }) {
|
||||
},
|
||||
}
|
||||
|
||||
store.i18n.extendDictionary(initialDictionary)
|
||||
if (Array.isArray(initialDictionary)) {
|
||||
dictionary = deepmerge.all(initialDictionary)
|
||||
} else {
|
||||
initialDictionary = dictionary
|
||||
}
|
||||
|
||||
return store
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
import { i18n } from '../src/index'
|
||||
import { Store } from 'svelte/store.umd'
|
||||
import { capital, title, upper, lower, isObject, warn } from '../src/utils'
|
||||
import { capital, title, upper, lower, isObject } from '../src/utils'
|
||||
|
||||
const store = new Store()
|
||||
let store = new Store()
|
||||
const locales = {
|
||||
'pt-br': {
|
||||
test: 'teste',
|
||||
@ -29,11 +29,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)
|
||||
|
Loading…
Reference in New Issue
Block a user