From 83971b26748c9a9d390fccd2db84a00e44233993 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 11 Dec 2021 00:15:54 +0100 Subject: [PATCH] Add messagesAdd in i18n init --- src/i18n/index.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/i18n/index.js b/src/i18n/index.js index 26e327901..e9f5773ee 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -70,9 +70,11 @@ export default () => { ...opts, messages: { ...config.messages, - ...(opts.messages || {}) - } + ...(opts.messages || {}), + }, }; + const add = this.config.messagesAdd; + add && this.addMessages(add); if (this.config.detectLocale) { this.config.locale = this._localLang(); @@ -127,9 +129,7 @@ export default () => { */ getMessages(lang, opts = {}) { const { messages } = this.config; - lang && - !messages[lang] && - this._debug(`'${lang}' i18n lang not found`, opts); + lang && !messages[lang] && this._debug(`'${lang}' i18n lang not found`, opts); return lang ? messages[lang] : messages; }, @@ -202,10 +202,8 @@ export default () => { // Try with fallback if (!result) result = this._getMsg(key, localeFlb, opts); - !result && - this._debug(`'${key}' i18n key not found in '${locale}' lang`, opts); - result = - result && isString(result) ? this._addParams(result, param) : result; + !result && this._debug(`'${key}' i18n key not found in '${locale}' lang`, opts); + result = result && isString(result) ? this._addParams(result, param) : result; return result; }, @@ -248,6 +246,6 @@ export default () => { destroy() { this.config = config; this.em = {}; - } + }, }; };