Repository: lingui/js-lingui (ts)

Issue:
<Plural /> not extracted
**Describe the bug**
When using the `<Plural />` component from `@lingui/macro` the translation is not extracted to the messages file.

**To Reproduce**
Steps to reproduce the behavior, possibly with minimal code sample, e.g:

```jsx
import { Plural } from "@lingui/macro"

export default function App() {
   return <Plural value={pagination.total} one="# Form" other="# Forms" />
}
```

And then run `npx lingui extract`

**Expected behavior**
I expect the messages json file to contain the following line:
` "{0, plural, one {# Form} other {# Forms}}": "{0, plural, one {# Form} other {# Forms}}",`

**Additional context**

- jsLingui version ``lingui --version``: 
```
"@lingui/cli": "^2.7.0",
"@lingui/macro": "^2.7.0",
"@lingui/react": "^2.7.0",
```
- Babel version ``npm list babel-core``
`"@babel/core": "^7.1.0"`
- Your Babel config (e.g. `.babelrc`) or framework you use (Create React App, Meteor, etc.)
Using create-react-app (`react-scripts@2.0.4`)
- lingui configuration
```json
  "lingui": {
    "sourceLocale": "en",
    "format": "minimal",
    "localeDir": "<rootDir>/src/locale",
    "srcPathDirs": [
      "src"
    ]
  },
```

Another odd thing is that if I add an empty `<Trans />` component somewhere in the file it does work. So the following code *does* correctly extract the plural translation.
```jsx
import { Plural, Trans } from "@lingui/macro"

export default function App() {
 return (
    <>
      <Trans />
      <Plural value={pagination.total} one="# Form" other="# Forms" />
    </>
  );
}
```



Pull request description:
Extract messages when Trans component is missing
Closes #382 

Patch:
diff --git a/packages/babel-plugin-extract-messages/src/index.js b/packages/babel-plugin-extract-messages/src/index.js
index ad0362be..6a5072e6 100644
--- a/packages/babel-plugin-extract-messages/src/index.js
+++ b/packages/babel-plugin-extract-messages/src/index.js
@@ -89,9 +89,9 @@ export default function({ types: t }) {
             importDeclarations[specifier.imported.name] = specifier.local.name
           })
 
-          if (importDeclarations["Trans"]) {
-            localTransComponentName = importDeclarations["Trans"]
-          }
+          // Trans import might be missing if there's just Plural or similar macro.
+          // If there's no alias, consider it was imported as Trans.
+          localTransComponentName = importDeclarations["Trans"] || "Trans"
         }
 
         // Remove imports of i18nMark identity


Test patch:
diff --git a/packages/babel-plugin-extract-messages/test/__snapshots__/index.js.snap b/packages/babel-plugin-extract-messages/test/__snapshots__/index.js.snap
index d1f4deb6..e41d1566 100644
--- a/packages/babel-plugin-extract-messages/test/__snapshots__/index.js.snap
+++ b/packages/babel-plugin-extract-messages/test/__snapshots__/index.js.snap
@@ -13,6 +13,19 @@ Object {
 }
 `;
 
+exports[`babel-plugin-lingui-extract-messages should extract Plural messages from JSX files when there's no Trans tag (integration) 1`] = `
+Object {
+  {count, plural, one {# book} other {# books}}: Object {
+    origin: Array [
+      Array [
+        packages/babel-plugin-extract-messages/test/fixtures/jsx/integration-without-trans.js,
+        3,
+      ],
+    ],
+  },
+}
+`;
+
 exports[`babel-plugin-lingui-extract-messages should extract all messages from JS files (integration) 1`] = `
 Object {
   msg.hello: Object {
diff --git a/packages/babel-plugin-extract-messages/test/fixtures/jsx/integration-without-trans.js b/packages/babel-plugin-extract-messages/test/fixtures/jsx/integration-without-trans.js
new file mode 100644
index 00000000..52c08330
--- /dev/null
+++ b/packages/babel-plugin-extract-messages/test/fixtures/jsx/integration-without-trans.js
@@ -0,0 +1,3 @@
+import { Plural } from "@lingui/macro";
+
+<Plural value={count} one="# book" other="# books" />
diff --git a/packages/babel-plugin-extract-messages/test/index.js b/packages/babel-plugin-extract-messages/test/index.js
index f38bb133..790c6081 100644
--- a/packages/babel-plugin-extract-messages/test/index.js
+++ b/packages/babel-plugin-extract-messages/test/index.js
@@ -156,6 +156,23 @@ describe("babel-plugin-lingui-extract-messages", function() {
     }
   )
 
+  testCase(
+    "should extract Plural messages from JSX files when there's no Trans tag (integration)",
+    transform => {
+      // first run should create all required folders and write messages
+      expect(transform("jsx/integration-without-trans.js")).not.toThrow()
+      // another runs should just write messages
+      expect(transform("jsx/integration-without-trans.js")).not.toThrow()
+
+      const messages = JSON.parse(
+        fs.readFileSync(
+          path.join(buildDir, "jsx", "integration-without-trans.js.json")
+        )
+      )
+      expect(messages).toMatchSnapshot()
+    }
+  )
+
   testCase("should extract all messages from JS files", transform => {
     // first run should create all required folders and write messages
     expect(transform("js/all.js", false)).not.toThrow()