Skip to content

Commit 82dea5f

Browse files
authored
feat: extract messages from specific files (#881)
1 parent 84273ab commit 82dea5f

14 files changed

Lines changed: 198 additions & 121 deletions

File tree

.github/workflows/release-test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: release-workflow-test
22

33
on:
4-
pull_request:
5-
branches:
6-
- '*'
74
push:
85
branches:
96
- main

docs/ref/cli.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Install
1616
.. code-block:: shell
1717
1818
npm install --save-dev @lingui/cli @babel/core
19-
# yarn add --dev @lingui/cli @babel/core
19+
# Or yarn
20+
yarn add --dev @lingui/cli @babel/core
2021
2122
2. Add following scripts to your ``package.json``:
2223

@@ -43,7 +44,7 @@ Commands
4344
``extract``
4445
-----------
4546

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

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

56+
.. lingui-cli-option:: [files...]
57+
58+
Filters source paths to only extract messages from passed files.
59+
For ex:
60+
61+
.. code-block:: shell
62+
63+
lingui extract src/components
64+
65+
Will extract only messages from ``src/components/**/*`` files, you can also pass multiple paths.
66+
67+
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:
68+
69+
.. code-block:: json
70+
71+
{
72+
"husky": {
73+
"hooks": {
74+
"pre-commit": "lingui extract $(git diff --name-only --staged)"
75+
}
76+
}
77+
}
78+
5579
.. lingui-cli-option:: --clean
5680

5781
Remove obsolete messages from catalogs. Message becomes obsolete

examples/create-react-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@lingui/react": "^3.1.0",
6+
"@lingui/react": "^3.2.3",
77
"@testing-library/jest-dom": "^5.11.5",
88
"@testing-library/react": "^11.1.0",
99
"@testing-library/user-event": "^12.1.10",
@@ -40,8 +40,8 @@
4040
]
4141
},
4242
"devDependencies": {
43-
"@lingui/cli": "^3.1.0",
44-
"@lingui/loader": "^3.1.0",
45-
"@lingui/macro": "^3.1.0"
43+
"@lingui/cli": "^3.2.3",
44+
"@lingui/loader": "^3.2.3",
45+
"@lingui/macro": "^3.2.3"
4646
}
4747
}

examples/create-react-app/yarn.lock

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,28 +1408,28 @@
14081408
"@types/yargs" "^15.0.0"
14091409
chalk "^4.0.0"
14101410

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

1421-
"@lingui/cli@3.1.0", "@lingui/cli@^3.1.0":
1422-
version "3.1.0"
1423-
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.1.0.tgz#bf541403f2d05dd02d79d42568a4b80c4a57ed75"
1424-
integrity sha512-/zYl7N+uiAUGL1spWqyOuCdBK6sE7YGQVL93n7VAE+lKlLrrjbu0mEGT8DpzBixFqt2JrY1H9M5cpJ4uMAGt/A==
1421+
"@lingui/cli@^3.2.3":
1422+
version "3.2.3"
1423+
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.2.3.tgz#40b83512edb468fe3b61da00c3f8885d9946c104"
1424+
integrity sha512-fsbiKrO8CO5dWy3hDQ6a8w0/m82Elv3UZ+T/LPyLT0spSxEVsZbJgySmomy2u/tYEkOEhXipkvoGR8mueaF8rA==
14251425
dependencies:
14261426
"@babel/generator" "^7.11.6"
14271427
"@babel/parser" "^7.11.5"
14281428
"@babel/plugin-syntax-jsx" "^7.10.4"
14291429
"@babel/runtime" "^7.11.2"
14301430
"@babel/types" "^7.11.5"
1431-
"@lingui/babel-plugin-extract-messages" "3.1.0"
1432-
"@lingui/conf" "3.1.0"
1431+
"@lingui/babel-plugin-extract-messages" "^3.2.3"
1432+
"@lingui/conf" "^3.2.3"
14331433
babel-plugin-macros "^2.8.0"
14341434
bcp-47 "^1.0.7"
14351435
chalk "^4.1.0"
@@ -1451,52 +1451,52 @@
14511451
pseudolocale "^1.1.0"
14521452
ramda "^0.27.1"
14531453

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

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

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

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

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

15011501
"@nodelib/fs.scandir@2.1.3":
15021502
version "2.1.3"

examples/js/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"pretest": "lingui compile --strict"
1313
},
1414
"dependencies": {
15-
"@lingui/core": "3.0.0",
16-
"@lingui/macro": "3.0.0"
15+
"@lingui/core": "^3.2.3",
16+
"@lingui/macro": "^3.2.3"
1717
},
1818
"devDependencies": {
1919
"@babel/core": "^7.12.3",
2020
"@babel/preset-env": "^7.12.1",
21-
"@lingui/cli": "3.0.0",
21+
"@lingui/cli": "^3.2.3",
2222
"babel-jest": "^26.6.1",
2323
"babel-plugin-macros": "^2.8.0",
2424
"jest": "^26.6.1"

examples/js/yarn.lock

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,28 +1291,28 @@
12911291
"@types/yargs" "^15.0.0"
12921292
chalk "^4.0.0"
12931293

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

1304-
"@lingui/cli@3.0.0":
1305-
version "3.0.0"
1306-
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.0.0.tgz#128ce8289d2fbc66cc6a122e1ccc76ff890b8ac7"
1307-
integrity sha512-ysega+gLQA46i6I9fkW1eQNhx2bYzRTaN0NfFtFxVu4WEIBP0+r+oHGTILys4zFjSj5v0iSJ/2/iroJKI11NeA==
1304+
"@lingui/cli@^3.2.3":
1305+
version "3.2.3"
1306+
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.2.3.tgz#40b83512edb468fe3b61da00c3f8885d9946c104"
1307+
integrity sha512-fsbiKrO8CO5dWy3hDQ6a8w0/m82Elv3UZ+T/LPyLT0spSxEVsZbJgySmomy2u/tYEkOEhXipkvoGR8mueaF8rA==
13081308
dependencies:
13091309
"@babel/generator" "^7.11.6"
13101310
"@babel/parser" "^7.11.5"
13111311
"@babel/plugin-syntax-jsx" "^7.10.4"
13121312
"@babel/runtime" "^7.11.2"
13131313
"@babel/types" "^7.11.5"
1314-
"@lingui/babel-plugin-extract-messages" "3.0.0"
1315-
"@lingui/conf" "3.0.0"
1314+
"@lingui/babel-plugin-extract-messages" "^3.2.3"
1315+
"@lingui/conf" "^3.2.3"
13161316
babel-plugin-macros "^2.8.0"
13171317
bcp-47 "^1.0.7"
13181318
chalk "^4.1.0"
@@ -1334,32 +1334,32 @@
13341334
pseudolocale "^1.1.0"
13351335
ramda "^0.27.1"
13361336

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

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

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

13651365
"@sinonjs/commons@^1.7.0":

examples/next-js/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
"start": "next start"
1111
},
1212
"dependencies": {
13-
"@lingui/core": "^3.1.0",
14-
"@lingui/react": "^3.1.0",
13+
"@lingui/core": "^3.2.3",
14+
"@lingui/react": "^3.2.3",
1515
"classnames": "^2.2.6",
1616
"next": "10.0.1",
1717
"react": "17.0.1",
1818
"react-dom": "17.0.1"
1919
},
2020
"devDependencies": {
21-
"@lingui/cli": "^3.1.0",
22-
"@lingui/loader": "^3.1.0",
23-
"@lingui/macro": "^3.1.0",
21+
"@lingui/cli": "^3.2.3",
22+
"@lingui/loader": "^3.2.3",
23+
"@lingui/macro": "^3.2.3",
2424
"@types/react": "^16.9.56",
2525
"babel-plugin-macros": "^2.8.0",
2626
"typescript": "^4.0.5"

0 commit comments

Comments
 (0)