diff --git a/src/i18n/index.js b/src/i18n/index.js index b9d6410c6..7a2624e22 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -29,7 +29,7 @@ * @module I18n */ import { keys, isUndefined } from 'underscore'; -import messages from './locale'; +import en from './locale/en'; export default () => { const { language } = window.navigator || {}; @@ -38,7 +38,7 @@ export default () => { locale: localeDef, localeFallback: 'en', counter: 'n', - messages + messages: { en } }; return { @@ -83,6 +83,7 @@ export default () => { * @private */ init(opts = {}) { + this.config = { ...config, ...opts }; this.em = opts.em; return this; }, diff --git a/test/specs/i18n/index.js b/test/specs/i18n/index.js index 211ff43ba..d1bb8653f 100644 --- a/test/specs/i18n/index.js +++ b/test/specs/i18n/index.js @@ -24,6 +24,23 @@ describe('I18n', () => { expect(obj.getLocale()).toBeTruthy(); }); + test('Init with config', () => { + const locale = 'it'; + const localeFallback = 'it'; + const msg = 'Hello!!!'; + obj.init({ + em, + locale, + localeFallback, + messages: { + en: { msg } + } + }); + expect(obj.getLocale()).toBe(locale); + expect(obj.getConfig().localeFallback).toBe(localeFallback); + expect(obj.getLocale()).toBe(locale); + }); + test('setLocale and getLocale methods', () => { const localeBefore = obj.getLocale(); const localeNew = `${localeBefore}2`;