Repository: lingui/js-lingui
Pull request #870 (2020-11-16 15:07:59)

docs: correct syntax error in I18nProvider example
Correct syntax error in I18nProvider example


Patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0028a2ed..663006e7 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -65,9 +65,15 @@ jobs:
           actor: 'lingui-bot'
           token: '${{ secrets.GH_TOKEN }}'
 
-      - name: Release packages
+      - name: Versioning packages
         env:
           GH_TOKEN: ${{secrets.GH_TOKEN}}
-        run: |
-          yarn version:${{github.event.inputs.npmTag}}
-          yarn release:${{github.event.inputs.npmTag}}
+        run: yarn version:${{github.event.inputs.npmTag}}
+
+      - name: Packaging packages with newer version
+        run: yarn release:build
+
+      - name: Publishing packages
+        env:
+          GH_TOKEN: ${{secrets.GH_TOKEN}}
+        run: yarn release:${{github.event.inputs.npmTag}}
diff --git a/docs/ref/react.rst b/docs/ref/react.rst
index 788315cb..2c36d4b0 100644
--- a/docs/ref/react.rst
+++ b/docs/ref/react.rst
@@ -173,7 +173,7 @@ top-level application component. However, if the ``locale`` is stored in a
    import React from 'react';
    import { I18nProvider } from '@lingui/react';
    import { i18n } from '@lingui/core';
-   import { messages as MessagesEn } from './locales/en/messages.js';
+   import { messages as messagesEn } from './locales/en/messages.js';
 
    i18n.load({
       en: messagesEn,
diff --git a/package.json b/package.json
index 2f9f8416..9e178721 100644
--- a/package.json
+++ b/package.json
@@ -20,8 +20,8 @@
     "release:integration": "node ./scripts/integration.js",
     "release:build": "node ./scripts/build/",
     "release:test": "node ./scripts/test.js",
-    "version:next": "lerna version --no-private --preid next --create-release github --conventional-commits --conventional-prerelease --yes",
-    "version:latest": "lerna version --no-private --create-release github --conventional-commits --yes",
+    "version:next": "lerna version --force-publish --no-private --preid next --create-release github --conventional-commits --conventional-prerelease --yes",
+    "version:latest": "lerna version --force-publish --no-private --create-release github --conventional-commits --yes",
     "release:latest": "lerna publish from-package --contents build --dist-tag latest --yes",
     "release:next": "lerna publish from-package --contents build --canary --preid next --pre-dist-tag next --yes",
     "build:docs": "cd docs && ./vercel-build.sh"
diff --git a/packages/cli/src/api/catalog.ts b/packages/cli/src/api/catalog.ts
index f316b382..0a17f420 100644
--- a/packages/cli/src/api/catalog.ts
+++ b/packages/cli/src/api/catalog.ts
@@ -252,7 +252,21 @@ export class Catalog {
       console.error(`Message with key ${key} is missing in locale ${locale}`)
     }
 
-    const getTranslation = (locale) => catalogs[locale][key].translation
+    const getTranslation = (locale) => {
+      const configLocales = this.config.locales.join('", "')
+      if (catalogs[locale]) {
+        return catalogs[locale][key].translation
+      }
+
+      console.warn(`
+        Catalog "${locale}" isn't present in locales config parameter
+        Add "${locale}" to your lingui.config.js:
+        {
+          locales: ["${configLocales}", "${locale}"]
+        }
+      `)
+      return null
+    }
 
     const getMultipleFallbacks = (locale) => {
       const fL = fallbackLocales[locale]
diff --git a/packages/conf/src/index.ts b/packages/conf/src/index.ts
index 0692c3de..9c09082b 100644
--- a/packages/conf/src/index.ts
+++ b/packages/conf/src/index.ts
@@ -278,7 +278,7 @@ export function fallbackLanguageMigration(
 
   config.locales.forEach((locale) => {
     const fl = getCldrParentLocale(locale.toLowerCase())
-    if (fl) {
+    if (fl && !config.fallbackLocales[locale]) {
       config.fallbackLocales = {
         ...config.fallbackLocales,
         [locale]: fl


Test patch:
diff --git a/packages/conf/src/index.test.ts b/packages/conf/src/index.test.ts
index cbd13c22..2ec6e15b 100644
--- a/packages/conf/src/index.test.ts
+++ b/packages/conf/src/index.test.ts
@@ -173,7 +173,7 @@ describe("@lingui/conf", function () {
         ),
       })
       expect(config.fallbackLocales).toEqual({
-        "en-US": "en",
+        "en-US": ["en"],
         default: "en",
         "es-MX": "es"
       })