diff --git a/src/server/__tests__/collectReactIntlTranslations.test.js b/src/server/__tests__/collectReactIntlTranslations.test.js index 1de5098..ea30ca4 100755 --- a/src/server/__tests__/collectReactIntlTranslations.test.js +++ b/src/server/__tests__/collectReactIntlTranslations.test.js @@ -58,4 +58,18 @@ describe('collectReactIntlTranslations', () => { }); expect(result).toEqual({ reactIntlId3: 'Hello {NAME}!' }); }); + + it('should include all keys with React Intl IDs, for the original lang', () => { + const result = collectReactIntlTranslations({ + originalLang: 'en', + lang: 'en', + keys: KEYS_INCLUDING_SOME_WITH_BRACES, + translations: [], + story: mainStory, + }); + expect(result).toEqual({ + reactIntlId1: 'Hello there!', + reactIntlId3: 'Hello {NAME}!' + }); + }); }); diff --git a/src/server/collectReactIntlTranslations.js b/src/server/collectReactIntlTranslations.js index c5c1044..3f1ee62 100755 --- a/src/server/collectReactIntlTranslations.js +++ b/src/server/collectReactIntlTranslations.js @@ -9,11 +9,13 @@ import type { } from '../common/types'; export default function collectReactIntlTranslations({ + originalLang, lang, keys, translations, story, }: {| + originalLang: string, lang: string, keys: MapOf, translations: Array, @@ -31,7 +33,7 @@ export default function collectReactIntlTranslations({ const key = keys[keyId]; const { reactIntlId } = key; if (!reactIntlId) return; - if (key.text.indexOf('{') >= 0) { + if (key.text.indexOf('{') >= 0 || lang === originalLang) { finalTranslations[reactIntlId] = key.text; } }); diff --git a/src/server/db.js b/src/server/db.js index 59272ef..35abc01 100755 --- a/src/server/db.js +++ b/src/server/db.js @@ -655,6 +655,7 @@ function compileTranslations({ story: baseStory }: { story?: StoryT } = {}) { if (_config.fReactIntlOutput) { const reactIntlLangPath = getReactIntlLangPath(lang); const reactIntlTranslations = collectReactIntlTranslations({ + originalLang: _config.originalLang, lang, keys, translations,