From 89bae28ee3534a13d47c8f404c6de4066bcb475a Mon Sep 17 00:00:00 2001 From: Anton Savoskin Date: Mon, 17 Jun 2019 17:23:15 +0700 Subject: [PATCH] fix(sync): bug with undefined message --- src/commands/sync.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/commands/sync.ts b/src/commands/sync.ts index 7eb756b..a9ab27d 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -93,13 +93,9 @@ export default class Extract extends Base { } const locales = langs.split(','); - this.messages = locales.reduce( - (acc, locale) => { - acc[locale] = {}; - return acc; - }, - {} as { [locale: string]: { [id: string]: Message } }, - ); + locales.forEach(locale => { + this.messages[locale] = {}; + }); await this.provider.getKeys(locales); await Promise.all(locales.map(locale => this.mergeToFile(locale))); @@ -108,7 +104,7 @@ export default class Extract extends Base { showInfo(`New translation keys: ${newMessages.length}`); if (provider === 'locize') { await asyncForEach(locales, locale => - this.provider!.uploadMessages(newMessages.map(id => this.messages[locale][id]), locale), + this.provider!.uploadMessages(newMessages.map(id => this.messages[locale][id]).filter(Boolean), locale), ); } else { await this.provider.uploadMessages(newMessages.map(id => this.messages[locales[0]][id]), 'en');