Skip to content

Commit 829a103

Browse files
p6l-richardemrysal
andauthoredJul 25, 2023
chore: enable i18n-unused GH action in website (#10296)
* regen yarn.lock? * chore: enable i18n-unused GH action in `website` * Generated yarn.lock with submodules * Added yarn.lock auth --------- Co-authored-by: Alex van Andel <me@alexvanandel.com>
1 parent db80afc commit 829a103

File tree

3 files changed

+103
-29
lines changed

3 files changed

+103
-29
lines changed
 

‎i18n-unused.config.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const path = require("path");
2+
3+
/**
4+
* # Regex for translation keys
5+
* This regex matches the following function calls:
6+
* 1. `t("<some_key>")`,
7+
* 2. `t("<some_key>", {key: "<some_string>"})`, or
8+
* 3. `<Trans i18nKey="home_hero_subtitle" t={t}>`
9+
*
10+
* It also ensure that we don't match any other similar function calls (e.g. `format("dddd")`).
11+
*
12+
* ## Explanation of the regex
13+
* - (?<!\w): negative lookbehind to ensure that there is no word character before "t" or "i18nKey"
14+
* - (?: ... ): non-capturing group
15+
* - t: for the use of `t("..")` OR `t("..", {key: ".."})`
16+
* - \(("[^"]*"): captures a string enclosed in double quotes followed by an opening parenthesis
17+
* - (?:,\s*\{[^}]*\})?: optional non-capturing group so that we match the optional interpolation object
18+
* - i18nKey=".+"[^\w]: for the usage of `<Trans i18nKey="home_hero_subtitle" t={t}>`
19+
*
20+
* */
21+
const translationKeyRegex = /(?<!\w)(?:t\(("[^"]*")(?:,\s*\{[^}]*\})?\)|i18nKey=".+"[^\w])/gi;
22+
23+
/** @type {import("i18n-unused/src/types/index.ts").RunOptions} */
24+
const config = {
25+
// localesPath: localePath, // uncomment to run on all locales (to calculate kb savings)
26+
localesPath: path.join("./apps/website", "/public/static/locales", "/en"),
27+
srcPath: "./apps/website",
28+
srcExtensions: ["ts", "tsx"],
29+
translationContextSeparator: ":",
30+
translationKeyMatcher: translationKeyRegex,
31+
missedTranslationParser: translationKeyRegex,
32+
ignorePaths: ["node_modules", ".next"],
33+
};
34+
35+
module.exports = config;

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"c8": "^7.13.0",
8383
"dotenv-checker": "^1.1.5",
8484
"husky": "^8.0.0",
85+
"i18n-unused": "^0.13.0",
8586
"jest-diff": "^29.5.0",
8687
"jsdom": "^22.0.0",
8788
"lint-staged": "^12.5.0",

‎yarn.lock

+67-29
Original file line numberDiff line numberDiff line change
@@ -4954,6 +4954,7 @@ __metadata:
49544954
globby: ^13.1.3
49554955
gray-matter: ^4.0.3
49564956
gsap: ^3.11.0
4957+
i18n-unused: ^0.13.0
49574958
iframe-resizer-react: ^1.1.0
49584959
keen-slider: ^6.8.0
49594960
lucide-react: ^0.171.0
@@ -7784,14 +7785,14 @@ __metadata:
77847785
languageName: node
77857786
linkType: hard
77867787

7787-
"@prisma/debug@npm:4.15.0":
7788-
version: 4.15.0
7789-
resolution: "@prisma/debug@npm:4.15.0"
7788+
"@prisma/debug@npm:5.0.0":
7789+
version: 5.0.0
7790+
resolution: "@prisma/debug@npm:5.0.0"
77907791
dependencies:
77917792
"@types/debug": 4.1.8
77927793
debug: 4.3.4
77937794
strip-ansi: 6.0.1
7794-
checksum: d911fbe540e2f6ecb3912fb871bedef63a6ded94e5f012b5afb580baf44c44dfddff095b22dbf9482bc62411217588892d723a42f0e8c497c20b9354e45ec081
7795+
checksum: 17d720717fab190a94762b90f93cfde799f419bfd2fee05c145566d6fa31d59d86dede80417234094afc5fff6d684ce350c17d40c302b26610ee60fe56c704e9
77957796
languageName: node
77967797
linkType: hard
77977798

@@ -7809,18 +7810,6 @@ __metadata:
78097810
languageName: node
78107811
linkType: hard
78117812

7812-
"@prisma/generator-helper@npm:^4.0.0":
7813-
version: 4.15.0
7814-
resolution: "@prisma/generator-helper@npm:4.15.0"
7815-
dependencies:
7816-
"@prisma/debug": 4.15.0
7817-
"@types/cross-spawn": 6.0.2
7818-
cross-spawn: 7.0.3
7819-
kleur: 4.1.5
7820-
checksum: a8692468b05a34b397bf7acc6fa71047ef7faaaa2208a14daac05efb80692a8592ec48c748bbe44e656095dc4fdaf2c77cd3b5bab2e29bce856ff6b0dac275ea
7821-
languageName: node
7822-
linkType: hard
7823-
78247813
"@prisma/generator-helper@npm:^4.13.0":
78257814
version: 4.13.0
78267815
resolution: "@prisma/generator-helper@npm:4.13.0"
@@ -7833,6 +7822,18 @@ __metadata:
78337822
languageName: node
78347823
linkType: hard
78357824

7825+
"@prisma/generator-helper@npm:^5.0.0":
7826+
version: 5.0.0
7827+
resolution: "@prisma/generator-helper@npm:5.0.0"
7828+
dependencies:
7829+
"@prisma/debug": 5.0.0
7830+
"@types/cross-spawn": 6.0.2
7831+
cross-spawn: 7.0.3
7832+
kleur: 4.1.5
7833+
checksum: 3506c9f23d2a7afcf4b99ad264f15efc7873f5e2ff9a7246a770c9ea7e7df627226a2e736890556c495cae3b0d1feaa3fd087417974500feaea14fb6da9dd0b0
7834+
languageName: node
7835+
linkType: hard
7836+
78367837
"@prisma/generator-helper@npm:~3.8.1":
78377838
version: 3.8.1
78387839
resolution: "@prisma/generator-helper@npm:3.8.1"
@@ -15698,6 +15699,7 @@ __metadata:
1569815699
dotenv-checker: ^1.1.5
1569915700
eslint: ^8.34.0
1570015701
husky: ^8.0.0
15702+
i18n-unused: ^0.13.0
1570115703
jest-diff: ^29.5.0
1570215704
jsdom: ^22.0.0
1570315705
lint-staged: ^12.5.0
@@ -16647,7 +16649,7 @@ __metadata:
1664716649
languageName: node
1664816650
linkType: hard
1664916651

16650-
"commander@npm:^8.3.0":
16652+
"commander@npm:^8.0.0, commander@npm:^8.3.0":
1665116653
version: 8.3.0
1665216654
resolution: "commander@npm:8.3.0"
1665316655
checksum: 0f82321821fc27b83bd409510bb9deeebcfa799ff0bf5d102128b500b7af22872c0c92cb6a0ebc5a4cf19c6b550fba9cedfa7329d18c6442a625f851377bacf0
@@ -19426,6 +19428,13 @@ __metadata:
1942619428
languageName: node
1942719429
linkType: hard
1942819430

19431+
"esm@npm:^3.2.25":
19432+
version: 3.2.25
19433+
resolution: "esm@npm:3.2.25"
19434+
checksum: 978aabe2de83541c105605a6d60a26ed8e627ef6bb0a7605fe15a95bbdea6b8348bd045255cb22219c054dd09a81a94823df00843d9e97f42419c92015ce3a64
19435+
languageName: node
19436+
linkType: hard
19437+
1942919438
"espree@npm:9.2.0":
1943019439
version: 9.2.0
1943119440
resolution: "espree@npm:9.2.0"
@@ -22398,6 +22407,19 @@ __metadata:
2239822407
languageName: node
2239922408
linkType: hard
2240022409

22410+
"i18n-unused@npm:^0.13.0":
22411+
version: 0.13.0
22412+
resolution: "i18n-unused@npm:0.13.0"
22413+
dependencies:
22414+
commander: ^8.0.0
22415+
esm: ^3.2.25
22416+
ts-import: ^2.0.39
22417+
bin:
22418+
i18n-unused: bin/i18n-unused.cjs
22419+
checksum: 000ad439edda9abf27ef3041ea96135f1b8a23632764ad6dad781fdf3e7483235e4fc863480707624f3ad2c48b555d5195b367fb3bbd54ac2e41c9ebcb88f8b5
22420+
languageName: node
22421+
linkType: hard
22422+
2240122423
"i18next-fs-backend@npm:^2.1.1":
2240222424
version: 2.1.3
2240322425
resolution: "i18next-fs-backend@npm:2.1.3"
@@ -22559,10 +22581,10 @@ __metadata:
2255922581
languageName: node
2256022582
linkType: hard
2256122583

22562-
"immer@npm:^9.0.15":
22563-
version: 9.0.21
22564-
resolution: "immer@npm:9.0.21"
22565-
checksum: 70e3c274165995352f6936695f0ef4723c52c92c92dd0e9afdfe008175af39fa28e76aafb3a2ca9d57d1fb8f796efc4dd1e1cc36f18d33fa5b74f3dfb0375432
22584+
"immer@npm:^10.0.2":
22585+
version: 10.0.2
22586+
resolution: "immer@npm:10.0.2"
22587+
checksum: 525a3b14210d02ae420c3b9f6ca14f7e9bcf625611d1356e773e7739f14c7c8de50dac442e6c7de3a6e24a782f7b792b6b8666bc0b3f00269d21a95f8f68ca84
2256622588
languageName: node
2256722589
linkType: hard
2256822590

@@ -27911,6 +27933,13 @@ __metadata:
2791127933
languageName: node
2791227934
linkType: hard
2791327935

27936+
"options-defaults@npm:^2.0.39":
27937+
version: 2.0.40
27938+
resolution: "options-defaults@npm:2.0.40"
27939+
checksum: 2bb3697a1aabecee4b76ee68857bd857957f664b78b419306a05e9c36182305092b0fca39035f287c75d24568326e06a0234d168290a9e9c88f1f2ce6e6dd977
27940+
languageName: node
27941+
linkType: hard
27942+
2791427943
"ora@npm:^5.4.1":
2791527944
version: 5.4.1
2791627945
resolution: "ora@npm:5.4.1"
@@ -29411,20 +29440,20 @@ __metadata:
2941129440
linkType: hard
2941229441

2941329442
"prisma-field-encryption@npm:^1.4.0":
29414-
version: 1.4.1
29415-
resolution: "prisma-field-encryption@npm:1.4.1"
29443+
version: 1.5.0
29444+
resolution: "prisma-field-encryption@npm:1.5.0"
2941629445
dependencies:
2941729446
"@47ng/cloak": ^1.1.0
29418-
"@prisma/generator-helper": ^4.0.0
29447+
"@prisma/generator-helper": ^5.0.0
2941929448
debug: ^4.3.4
29420-
immer: ^9.0.15
29449+
immer: ^10.0.2
2942129450
object-path: ^0.11.8
29422-
zod: ^3.17.3
29451+
zod: ^3.21.4
2942329452
peerDependencies:
29424-
"@prisma/client": ^3.8.0 || ^4
29453+
"@prisma/client": ">= 4.7"
2942529454
bin:
2942629455
prisma-field-encryption: dist/generator/main.js
29427-
checksum: cf059abc1c39ae9252494aaf6ce2bfa0f415583b8cd11b9d84eeadfbb504e00f61570b0e3158ba4b7d52daf91353ffe92766a717c03b9965c421cc08ed49c303
29456+
checksum: 530bd970c5015c8c587bdca24136262d746093dd3d0793c892f4a1c377633182ae95e0ef5659465f914e4cc9bd7b24bf45551aa9c624a05942570f5b650fc065
2942829457
languageName: node
2942929458
linkType: hard
2943029459

@@ -34628,6 +34657,15 @@ __metadata:
3462834657
languageName: node
3462934658
linkType: hard
3463034659

34660+
"ts-import@npm:^2.0.39":
34661+
version: 2.0.40
34662+
resolution: "ts-import@npm:2.0.40"
34663+
dependencies:
34664+
options-defaults: ^2.0.39
34665+
checksum: 9d05df5825a88fcc57b069fab6ee52d405350a60d214c0df2d6288a69b6160ee80ac10f5bceab055698935987441f7f13fefb887654b32f157d3ef19ce4856b4
34666+
languageName: node
34667+
linkType: hard
34668+
3463134669
"ts-interface-checker@npm:^0.1.9":
3463234670
version: 0.1.13
3463334671
resolution: "ts-interface-checker@npm:0.1.13"
@@ -37775,7 +37813,7 @@ __metadata:
3777537813
languageName: node
3777637814
linkType: hard
3777737815

37778-
"zod@npm:3.21.4, zod@npm:^3.17.3":
37816+
"zod@npm:3.21.4, zod@npm:^3.21.4":
3777937817
version: 3.21.4
3778037818
resolution: "zod@npm:3.21.4"
3778137819
checksum: f185ba87342ff16f7a06686767c2b2a7af41110c7edf7c1974095d8db7a73792696bcb4a00853de0d2edeb34a5b2ea6a55871bc864227dace682a0a28de33e1f

0 commit comments

Comments
 (0)