From 1f7601e73a006d8048881a6080d80692b12f09ce Mon Sep 17 00:00:00 2001 From: Ahmad Bamieh Date: Wed, 2 Oct 2019 16:40:15 +0300 Subject: [PATCH 1/2] Update .i18nrc.json --- .../kbn-plugin-generator/sao_template/template/.i18nrc.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/kbn-plugin-generator/sao_template/template/.i18nrc.json b/packages/kbn-plugin-generator/sao_template/template/.i18nrc.json index edcca37a248f0..3fb2834877898 100644 --- a/packages/kbn-plugin-generator/sao_template/template/.i18nrc.json +++ b/packages/kbn-plugin-generator/sao_template/template/.i18nrc.json @@ -1,5 +1,8 @@ { "paths": { "<%= camelCase(name) %>": "./" - } + }, + "translations": [ + "translations/zh-CN.json" + ] } From aa881f74741ad3fa9d74a698c7ec06b3b2f18df0 Mon Sep 17 00:00:00 2001 From: Ahmad Bamieh Date: Wed, 2 Oct 2019 16:44:19 +0300 Subject: [PATCH 2/2] Update get_translations_path.js --- src/legacy/server/i18n/get_translations_path.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/legacy/server/i18n/get_translations_path.js b/src/legacy/server/i18n/get_translations_path.js index 95de6c7560660..6ac3e75e1d4a8 100644 --- a/src/legacy/server/i18n/get_translations_path.js +++ b/src/legacy/server/i18n/get_translations_path.js @@ -34,10 +34,12 @@ export async function getTranslationPaths({ cwd, glob }) { try { const content = await readFileAsync(entryFullPath, 'utf8'); const { translations } = JSON.parse(content); - translations.forEach(translation => { - const translationFullPath = resolve(pluginBasePath, translation); - translationPaths.push(translationFullPath); - }); + if (translations && translations.length) { + translations.forEach(translation => { + const translationFullPath = resolve(pluginBasePath, translation); + translationPaths.push(translationFullPath); + }); + } } catch (err) { throw new Error(`Failed to parse .i18nrc.json file at ${entryFullPath}`); }