Repository: lingui/js-lingui
Pull request #872 (2020-11-16 21:37:22)

docs: remove add-locale from documentation
Removes information about running deprecated add-locale command from React documentation


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/docs/tutorials/setup-react.rst b/docs/tutorials/setup-react.rst
index 5bee2d59..12f45ad0 100644
--- a/docs/tutorials/setup-react.rst
+++ b/docs/tutorials/setup-react.rst
@@ -62,6 +62,7 @@ Install
    .. code-block:: json
 
       {
+         "locales": ["en", "cs"],
          "localeDir": "src/locales/",
          "srcPathDirs": ["src/"],
          "format": "po"
@@ -76,24 +77,12 @@ Install
 
       {
          "scripts": {
-            "add-locale": "lingui add-locale",
             "extract": "lingui extract",
             "compile": "lingui compile",
          }
       }
 
-5. Run ``npm run add-locale`` (or ``yarn add-locale``) with
-   `locale codes <https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry>`_
-   you would like to use in your app:
-
-   .. code-block:: shell
-
-      npm run add-locale en es fr  # Add English, Spanish and French locale
-
-      # or using Yarn
-      yarn add-locale en es fr
-
-6. Check the installation by running ``npm run extract`` (or ``yarn extract``):
+5. Check the installation by running ``npm run extract`` (or ``yarn extract``):
 
    .. code-block:: shell
 
@@ -117,7 +106,6 @@ Install
       │ fr       │     0       │   0     │
       └──────────┴─────────────┴─────────┘
 
-      (use "lingui add-locale <language>" to add more locales)
       (use "lingui extract" to update catalogs with new messages)
       (use "lingui compile" to compile catalogs for production)
 
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"
       })