Skip to content

Commit

Permalink
feat: extract messages from specific files (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
semoal committed Nov 23, 2020
1 parent 84273ab commit 82dea5f
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 121 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/release-test.yml
@@ -1,9 +1,6 @@
name: release-workflow-test

on:
pull_request:
branches:
- '*'
push:
branches:
- main
Expand Down
28 changes: 26 additions & 2 deletions docs/ref/cli.rst
Expand Up @@ -16,7 +16,8 @@ Install
.. code-block:: shell
npm install --save-dev @lingui/cli @babel/core
# yarn add --dev @lingui/cli @babel/core
# Or yarn
yarn add --dev @lingui/cli @babel/core
2. Add following scripts to your ``package.json``:

Expand All @@ -43,7 +44,7 @@ Commands
``extract``
-----------

.. lingui-cli:: extract [--clean] [--overwrite] [--format <format>] [--locale <locale>] [--convert-from <format>] [--verbose]
.. lingui-cli:: extract [files...] [--clean] [--overwrite] [--format <format>] [--locale <locale>] [--convert-from <format>] [--verbose]

This command extracts messages from source files and creates a message catalog for
each language using the following steps:
Expand All @@ -52,6 +53,29 @@ each language using the following steps:
2. Merge them with existing catalogs in :conf:`localeDir` (if any)
3. Write updated message catalogs to :conf:`localeDir`

.. lingui-cli-option:: [files...]

Filters source paths to only extract messages from passed files.
For ex:

.. code-block:: shell
lingui extract src/components
Will extract only messages from ``src/components/**/*`` files, you can also pass multiple paths.

It's useful if you want to run extract command on files that are staged, using for example ``husky``, before commiting will extract messages from staged files:

.. code-block:: json
{
"husky": {
"hooks": {
"pre-commit": "lingui extract $(git diff --name-only --staged)"
}
}
}
.. lingui-cli-option:: --clean

Remove obsolete messages from catalogs. Message becomes obsolete
Expand Down
8 changes: 4 additions & 4 deletions examples/create-react-app/package.json
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@lingui/react": "^3.1.0",
"@lingui/react": "^3.2.3",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand Down Expand Up @@ -40,8 +40,8 @@
]
},
"devDependencies": {
"@lingui/cli": "^3.1.0",
"@lingui/loader": "^3.1.0",
"@lingui/macro": "^3.1.0"
"@lingui/cli": "^3.2.3",
"@lingui/loader": "^3.2.3",
"@lingui/macro": "^3.2.3"
}
}
70 changes: 35 additions & 35 deletions examples/create-react-app/yarn.lock
Expand Up @@ -1408,28 +1408,28 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@lingui/babel-plugin-extract-messages@3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-3.1.0.tgz#6c24e3082ef205bc0b1b056c112f1b52a3b7cc81"
integrity sha512-8wDae+HxpGrN/gsT+fLo+cTkzlE1V9hwMHLmjQ6uA26emyPtXQrJnltHi+gbDYFf/JJgvmVpo6HvqWvn9Kvo9Q==
"@lingui/babel-plugin-extract-messages@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-3.2.3.tgz#59f861bb02edb7eb4d29d1d283a3351f98b4e4f4"
integrity sha512-F1N6cwjxSxKClUT4yfRnRtJ6lkUckrDx73RSbVL7OgrefQzZS9/RjnufULPV0kU9p1XDKfaBI1YHR4zQvdR+5A==
dependencies:
"@babel/generator" "^7.11.6"
"@babel/runtime" "^7.11.2"
"@lingui/conf" "3.1.0"
"@lingui/conf" "^3.2.3"
mkdirp "^1.0.4"

"@lingui/cli@3.1.0", "@lingui/cli@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.1.0.tgz#bf541403f2d05dd02d79d42568a4b80c4a57ed75"
integrity sha512-/zYl7N+uiAUGL1spWqyOuCdBK6sE7YGQVL93n7VAE+lKlLrrjbu0mEGT8DpzBixFqt2JrY1H9M5cpJ4uMAGt/A==
"@lingui/cli@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.2.3.tgz#40b83512edb468fe3b61da00c3f8885d9946c104"
integrity sha512-fsbiKrO8CO5dWy3hDQ6a8w0/m82Elv3UZ+T/LPyLT0spSxEVsZbJgySmomy2u/tYEkOEhXipkvoGR8mueaF8rA==
dependencies:
"@babel/generator" "^7.11.6"
"@babel/parser" "^7.11.5"
"@babel/plugin-syntax-jsx" "^7.10.4"
"@babel/runtime" "^7.11.2"
"@babel/types" "^7.11.5"
"@lingui/babel-plugin-extract-messages" "3.1.0"
"@lingui/conf" "3.1.0"
"@lingui/babel-plugin-extract-messages" "^3.2.3"
"@lingui/conf" "^3.2.3"
babel-plugin-macros "^2.8.0"
bcp-47 "^1.0.7"
chalk "^4.1.0"
Expand All @@ -1451,52 +1451,52 @@
pseudolocale "^1.1.0"
ramda "^0.27.1"

"@lingui/conf@3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-3.1.0.tgz#953b71ceef9cf0a07091892a927b16b59577d42a"
integrity sha512-DhBGeOC4qY0tjVwTdwLr59YjqcRPfA7+Ehj346cJZXkfLylCb4TLKIhnGJbDF7lReNWDltECJCHxvPfotre6Vw==
"@lingui/conf@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-3.2.3.tgz#ab3ac70eef8f2f219ce85d8b8516ecc128af477a"
integrity sha512-9Zfq/Z0vH9BucaXVbeIIoWDb7RsnqBizdHn9+PUzQx5AiudzBeKrW8gF0IGxFwugFoS5ho8qVLovYoDS2JSDYA==
dependencies:
"@babel/runtime" "^7.11.2"
chalk "^4.1.0"
cosmiconfig "^7.0.0"
jest-validate "^26.5.2"

"@lingui/core@3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/core/-/core-3.1.0.tgz#c8e185cee881ccc935ab9c2d363d620c006901f7"
integrity sha512-dKUcX2Swm8bjed6qIRYQ9xUv6Yq3kxzfKm+jtdLQCO3hlfq/w6Zt16EsAgeJZ92081ZhlJLNGy/dELEczajUBw==
"@lingui/core@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/core/-/core-3.2.3.tgz#2eeba173d3a3a1cbe9f9de4ed57380d2dc45ecff"
integrity sha512-TiWk6LGjZ9sNVi7itiJDWUIB1Uyr8WKR/8M6RhQVTRnL+Yh3mElsVPjIRPH1he4ClkwaH6G5eDOfWiB67Csgbw==
dependencies:
"@babel/runtime" "^7.11.2"
make-plural "^6.2.2"
messageformat-parser "^4.1.3"

"@lingui/loader@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/loader/-/loader-3.1.0.tgz#9a9124cd9e5b71c2361e5e446522b72ad8cde5bb"
integrity sha512-dUnLykFdLruV/5hjQREcLdoNA3aInddhLEp5fiAIGElxlfVPj77YZZzEJBBUJ/v7v+48AyPOOPmbcbhHfb1BsQ==
"@lingui/loader@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/loader/-/loader-3.2.3.tgz#13468bc294da4d4f88d00e7bec3ebe2ef83b8d59"
integrity sha512-ylyvPeWjomCXZIZC8SZ0VAuhR62vt+jghYdkB0QQbxzgMkwZLTkaA1zGW7im0mjrI0Hwa4PgXCivS7K3krwxSw==
dependencies:
"@babel/runtime" "^7.11.2"
"@lingui/cli" "3.1.0"
"@lingui/conf" "3.1.0"
"@lingui/cli" "^3.2.3"
"@lingui/conf" "^3.2.3"
loader-utils "^2.0.0"
ramda "^0.27.1"

"@lingui/macro@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-3.1.0.tgz#ae98371964cf716f96b67b7207c9d00f4471e0f2"
integrity sha512-yE8FGLV0175wAh9nSNOFjtyYITHsA98IRFyMn/OqLbDDummdvahXQrQPtO8SQ/ecVJdh7LrZGmsYawCFVQ2XQg==
"@lingui/macro@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-3.2.3.tgz#d054f9f6008b068a134d7bb3bfe87b3573c5d556"
integrity sha512-XcGUD8qQe8b351qGA/AyX+WKQWJu3T/r8wlXsttKoeFd7OXIitAw53L+OLc6xauM5xUssdaWo6BtOJnLw034gA==
dependencies:
"@babel/runtime" "^7.11.2"
"@lingui/conf" "3.1.0"
"@lingui/conf" "^3.2.3"
ramda "^0.27.1"

"@lingui/react@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@lingui/react/-/react-3.1.0.tgz#ff650b03c3a29cb2576941032b916a63d3b2b2c2"
integrity sha512-a3eYTcV8V5fhF0k/BxAT2DQNHlY2UPRvZqeA3OkQvkREptExVeNzo3gfS0bdyOGvJIpILFFBIVtxUhvHSU+dmQ==
"@lingui/react@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/react/-/react-3.2.3.tgz#8cf78a217d4a2314ab38c68521a6dd544f87b258"
integrity sha512-oPqy7LhJddBDvgDvfKikZh8sFP4uG1/NaDhIkHXVCwf+ONxuAwsDPvW47e/K5hQ60UX2LqGbbB7LuAFK5Klr1Q==
dependencies:
"@babel/runtime" "^7.11.2"
"@lingui/core" "3.1.0"
"@lingui/core" "^3.2.3"

"@nodelib/fs.scandir@2.1.3":
version "2.1.3"
Expand Down
6 changes: 3 additions & 3 deletions examples/js/package.json
Expand Up @@ -12,13 +12,13 @@
"pretest": "lingui compile --strict"
},
"dependencies": {
"@lingui/core": "3.0.0",
"@lingui/macro": "3.0.0"
"@lingui/core": "^3.2.3",
"@lingui/macro": "^3.2.3"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@lingui/cli": "3.0.0",
"@lingui/cli": "^3.2.3",
"babel-jest": "^26.6.1",
"babel-plugin-macros": "^2.8.0",
"jest": "^26.6.1"
Expand Down
48 changes: 24 additions & 24 deletions examples/js/yarn.lock
Expand Up @@ -1291,28 +1291,28 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@lingui/babel-plugin-extract-messages@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-3.0.0.tgz#5bc2c08ccde0ebbe736d5ee22cd0b61bc837f7f1"
integrity sha512-atjb6sQbDP8ZLZu5fJdAMK+CJWGs/hyn52JxZi3tPgirORFDAOa/FfDP5Sfnv+3wgEQzFA2igEmSKpyTuyZHBg==
"@lingui/babel-plugin-extract-messages@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-3.2.3.tgz#59f861bb02edb7eb4d29d1d283a3351f98b4e4f4"
integrity sha512-F1N6cwjxSxKClUT4yfRnRtJ6lkUckrDx73RSbVL7OgrefQzZS9/RjnufULPV0kU9p1XDKfaBI1YHR4zQvdR+5A==
dependencies:
"@babel/generator" "^7.11.6"
"@babel/runtime" "^7.11.2"
"@lingui/conf" "3.0.0"
"@lingui/conf" "^3.2.3"
mkdirp "^1.0.4"

"@lingui/cli@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.0.0.tgz#128ce8289d2fbc66cc6a122e1ccc76ff890b8ac7"
integrity sha512-ysega+gLQA46i6I9fkW1eQNhx2bYzRTaN0NfFtFxVu4WEIBP0+r+oHGTILys4zFjSj5v0iSJ/2/iroJKI11NeA==
"@lingui/cli@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.2.3.tgz#40b83512edb468fe3b61da00c3f8885d9946c104"
integrity sha512-fsbiKrO8CO5dWy3hDQ6a8w0/m82Elv3UZ+T/LPyLT0spSxEVsZbJgySmomy2u/tYEkOEhXipkvoGR8mueaF8rA==
dependencies:
"@babel/generator" "^7.11.6"
"@babel/parser" "^7.11.5"
"@babel/plugin-syntax-jsx" "^7.10.4"
"@babel/runtime" "^7.11.2"
"@babel/types" "^7.11.5"
"@lingui/babel-plugin-extract-messages" "3.0.0"
"@lingui/conf" "3.0.0"
"@lingui/babel-plugin-extract-messages" "^3.2.3"
"@lingui/conf" "^3.2.3"
babel-plugin-macros "^2.8.0"
bcp-47 "^1.0.7"
chalk "^4.1.0"
Expand All @@ -1334,32 +1334,32 @@
pseudolocale "^1.1.0"
ramda "^0.27.1"

"@lingui/conf@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-3.0.0.tgz#8a3ea64e7a7c43d12c20aa910d6aeb65911d889b"
integrity sha512-oPPU6hdyA2fMlQRB7GoYWApzR2tTXPqN8bGTo3ZFXBOgazAHYgIED/ZrnXEWTKRdGRtxMYkU+xDQ+6BLdgieug==
"@lingui/conf@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-3.2.3.tgz#ab3ac70eef8f2f219ce85d8b8516ecc128af477a"
integrity sha512-9Zfq/Z0vH9BucaXVbeIIoWDb7RsnqBizdHn9+PUzQx5AiudzBeKrW8gF0IGxFwugFoS5ho8qVLovYoDS2JSDYA==
dependencies:
"@babel/runtime" "^7.11.2"
chalk "^4.1.0"
cosmiconfig "^7.0.0"
jest-validate "^26.5.2"

"@lingui/core@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@lingui/core/-/core-3.0.0.tgz#5591658ea4edaf0e5fc359eef5b70fe292a22265"
integrity sha512-Jtwau0dV10SaL/mJmhR+h5Pyos3MTijWvNnPeIiaKfVtXskhopspuKjux0Q2BeDipmGXMxcF6JAuVJvTFxJ47w==
"@lingui/core@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/core/-/core-3.2.3.tgz#2eeba173d3a3a1cbe9f9de4ed57380d2dc45ecff"
integrity sha512-TiWk6LGjZ9sNVi7itiJDWUIB1Uyr8WKR/8M6RhQVTRnL+Yh3mElsVPjIRPH1he4ClkwaH6G5eDOfWiB67Csgbw==
dependencies:
"@babel/runtime" "^7.11.2"
make-plural "^6.2.2"
messageformat-parser "^4.1.3"

"@lingui/macro@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-3.0.0.tgz#afdc4890251e38b657e7c1b4bb357e5a36bf6637"
integrity sha512-Gugk8u1tlFEsaQnfzMidDdsbq/OFs3VYZ8H8XfEvygyNtWMZgKjbe1bPpwHEf4+fS3YJHWg/0GfHwIfzbJMP5g==
"@lingui/macro@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-3.2.3.tgz#d054f9f6008b068a134d7bb3bfe87b3573c5d556"
integrity sha512-XcGUD8qQe8b351qGA/AyX+WKQWJu3T/r8wlXsttKoeFd7OXIitAw53L+OLc6xauM5xUssdaWo6BtOJnLw034gA==
dependencies:
"@babel/runtime" "^7.11.2"
"@lingui/conf" "3.0.0"
"@lingui/conf" "^3.2.3"
ramda "^0.27.1"

"@sinonjs/commons@^1.7.0":
Expand Down
10 changes: 5 additions & 5 deletions examples/next-js/package.json
Expand Up @@ -10,17 +10,17 @@
"start": "next start"
},
"dependencies": {
"@lingui/core": "^3.1.0",
"@lingui/react": "^3.1.0",
"@lingui/core": "^3.2.3",
"@lingui/react": "^3.2.3",
"classnames": "^2.2.6",
"next": "10.0.1",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"devDependencies": {
"@lingui/cli": "^3.1.0",
"@lingui/loader": "^3.1.0",
"@lingui/macro": "^3.1.0",
"@lingui/cli": "^3.2.3",
"@lingui/loader": "^3.2.3",
"@lingui/macro": "^3.2.3",
"@types/react": "^16.9.56",
"babel-plugin-macros": "^2.8.0",
"typescript": "^4.0.5"
Expand Down

1 comment on commit 82dea5f

@vercel
Copy link

@vercel vercel bot commented on 82dea5f Nov 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.