locale-keysmith 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # locale-keysmith
2
2
 
3
- Sort, audit, clean, and translate locale files from the command line.
3
+ Sort, audit, clean, and translate i18n locale files from the command line.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,53 +8,320 @@ Sort, audit, clean, and translate locale files from the command line.
8
8
  pnpm add -D locale-keysmith
9
9
  ```
10
10
 
11
+ Requires Node.js 22.12 or newer.
12
+
13
+ ## Quick start
14
+
15
+ ```bash
16
+ # Write a starter config based on the locale files in your project (optional)
17
+ pnpm exec locale-keysmith init
18
+
19
+ # See which locale files are detected
20
+ pnpm exec locale-keysmith scan
21
+
22
+ # Get a full report: missing keys, unused keys, and unsorted files
23
+ pnpm exec locale-keysmith health
24
+ ```
25
+
26
+ By default everything is scanned under the `src` folder. To look elsewhere, add a config
27
+ file (see [Configuration](#configuration)).
28
+
11
29
  ## Commands
12
30
 
31
+ Run a command with `pnpm exec locale-keysmith <command>` (or `npx locale-keysmith <command>`).
32
+
33
+ | Command | What it does |
34
+ | -------------------------- | ------------------------------------------------------------------------ |
35
+ | `init` | Write a starter `locale-keysmith.config.json` for this project. |
36
+ | `scan` | List the locale files that were found, with their inferred locale. |
37
+ | `health` | Run every check below plus extra keys, empty values and type mismatches. |
38
+ | `missing` | List keys present in the source locale but missing from the others. |
39
+ | `unused` | List source-locale keys that no source file references. |
40
+ | `sort` | Sort every locale file's keys alphabetically (nested too). |
41
+ | `remove-unused` | Delete unused keys from every locale file. |
42
+ | `translate --to <locales>` | Fill missing keys in target locales via Google Translate. |
43
+
44
+ ### Using it in CI
45
+
46
+ `scan`, `missing`, `unused` and `health` accept `--json` and print a machine-readable
47
+ result on stdout (warnings go to stderr, so stdout always parses):
48
+
49
+ ```bash
50
+ pnpm exec locale-keysmith health --json
51
+ ```
52
+
53
+ ```json
54
+ {
55
+ "healthy": false,
56
+ "issueCount": 1,
57
+ "issues": [{ "type": "missing", "file": "src/locales/de.json", "locale": "de", "key": "status.offline" }]
58
+ }
59
+ ```
60
+
61
+ Exit codes:
62
+
63
+ | Code | Meaning |
64
+ | ---- | --------------------------------------------------------------------------------- |
65
+ | `0` | Nothing to report. |
66
+ | `1` | `missing`, `unused` or `health` found something. |
67
+ | `2` | The command itself failed (invalid config, unreadable locale file, API error...). |
68
+
69
+ ### `init`
70
+
71
+ ```bash
72
+ pnpm exec locale-keysmith init # refuses to overwrite an existing config
73
+ pnpm exec locale-keysmith init --force # overwrite it
74
+ ```
75
+
76
+ Looks for locale files in the project (skipping `node_modules`, build output, and test or
77
+ fixture folders) and writes a config with:
78
+
79
+ - `sourceLocale`: `en` (or an English variant) when present, otherwise the locale with the most
80
+ keys.
81
+ - `roots`: the top-level folders that hold locale files, plus `src`, `app`, `pages`,
82
+ `components`, `lib` and `packages` when they exist.
83
+
84
+ ### `scan`
85
+
13
86
  ```bash
14
87
  pnpm exec locale-keysmith scan
15
- pnpm exec locale-keysmith sort --write
88
+ ```
89
+
90
+ Prints one line per detected locale file, e.g. `en src/locales/en.json`. Matched JSON/YAML
91
+ files that are not locale files (see [How locale files are recognised](#how-locale-files-are-recognised))
92
+ are listed underneath as skipped, so you can see why a file you expected is missing:
93
+
94
+ ```
95
+ en src/locales/en.json
96
+ de src/locales/de.json
97
+
98
+ Skipped 1 file whose name or folder is not a locale code:
99
+ src/locales/english.json
100
+ ```
101
+
102
+ With `--json`, the skipped files are in the `skipped` array.
103
+
104
+ ### `health`
105
+
106
+ ```bash
107
+ pnpm exec locale-keysmith health
108
+ ```
109
+
110
+ A one-shot audit. It prints each problem it finds:
111
+
112
+ ```
113
+ unsorted src/locales/de.json
114
+ duplicate en nav.home
115
+ missing de status.offline
116
+ extra de legacy.oldButton
117
+ empty de app.tagline
118
+ type-mismatch de menu (object in the source, string here)
119
+ unused draft.placeholder
120
+
121
+ 7 issues found.
122
+ ```
123
+
124
+ | Issue | Meaning |
125
+ | --------------- | ----------------------------------------------------------------------------- |
126
+ | `unsorted` | The file's keys are not in alphabetical order (fix with `sort --write`). |
127
+ | `duplicate` | The file defines a key twice, e.g. `"nav.home"` and `"nav": { "home" }`. |
128
+ | `missing` | A key from the source locale is absent in this locale. |
129
+ | `extra` | This locale has a key the source locale does not (often a leftover). |
130
+ | `empty` | The value is an empty or whitespace-only string, or `null`. |
131
+ | `type-mismatch` | The key holds a different kind of value than in the source (text vs. object). |
132
+ | `unused` | No source file references the key. |
133
+
134
+ It exits with a non-zero status when any issue is found, so it can gate CI. When everything
135
+ is fine it prints `All locale files are healthy.` and exits `0`. Keys matching `ignoreKeys`
136
+ are skipped by every check.
137
+
138
+ ### `missing`
139
+
140
+ ```bash
16
141
  pnpm exec locale-keysmith missing
142
+ ```
143
+
144
+ Lists, per non-source locale, the keys that exist in the source locale but are absent.
145
+
146
+ Plural keys follow each language's plural rules, as i18next does: English `item_one` /
147
+ `item_other` means Polish needs `item_one`, `item_few`, `item_many` and `item_other`, while
148
+ Japanese only needs `item_other`. Neither is reported as missing or extra for doing so, and
149
+ `translate` fills plural forms the source language lacks from its `_other` text.
150
+
151
+ ### `unused`
152
+
153
+ ```bash
17
154
  pnpm exec locale-keysmith unused
18
- pnpm exec locale-keysmith remove-unused --dry-run
155
+ ```
156
+
157
+ Lists source-locale keys that are never referenced in your source files. See
158
+ [Key usage detection](#key-usage-detection) for exactly what counts as "referenced".
159
+
160
+ ### `sort`
161
+
162
+ ```bash
163
+ pnpm exec locale-keysmith sort # preview (no changes written)
164
+ pnpm exec locale-keysmith sort --write # write sorted files to disk
165
+ ```
166
+
167
+ Sorts keys alphabetically at every nesting level. Without `--write` it only reports which
168
+ files would change.
169
+
170
+ ### `remove-unused`
171
+
172
+ ```bash
173
+ pnpm exec locale-keysmith remove-unused # preview
174
+ pnpm exec locale-keysmith remove-unused --dry-run # preview (explicit)
175
+ pnpm exec locale-keysmith remove-unused --write # delete unused keys and re-sort
176
+ ```
177
+
178
+ Removes unused keys from **every** locale file (not just the source), then re-sorts them.
179
+ It lists every key it removes; without `--write` it only lists the keys that would be removed.
180
+
181
+ ### `translate`
182
+
183
+ ```bash
184
+ export GOOGLE_TRANSLATE_API_KEY="your-api-key"
185
+ pnpm exec locale-keysmith translate --to de,fr # preview counts
19
186
  pnpm exec locale-keysmith translate --from en --to de,fr --write
20
187
  ```
21
188
 
22
- ## Config
189
+ Translates the source locale's missing keys into each target locale using the Google
190
+ Translate API. A target locale that has no file yet is created next to the source file. Keys
191
+ matching `ignoreKeys` are not translated.
192
+
193
+ | Option | Default | Description |
194
+ | ----------------- | ----------------------- | ----------------------------------------------- |
195
+ | `--to <locales>` | — | Comma-separated target locales (required). |
196
+ | `--from <locale>` | `sourceLocale` (config) | Source locale to translate from. |
197
+ | `--write` | off | Write results to disk (otherwise preview only). |
198
+
199
+ Requires the `GOOGLE_TRANSLATE_API_KEY` environment variable; it is sent in a request header,
200
+ never in the URL.
201
+
202
+ - **Placeholders are protected.** `{{name}}`, `{count}`, ICU messages such as
203
+ `{count, plural, ...}`, `<0>…</0>` and other tags, `$t(key)` and `%s` are passed through
204
+ untranslated. If a translation comes back with a placeholder missing, that key is skipped
205
+ with a warning rather than written broken. (The text inside an ICU message is kept as is.)
206
+ - **Progress is saved.** If a request fails midway, the keys translated so far are written
207
+ before the error is reported, so rerunning only translates what is left.
208
+ - Keys are sent in batches of up to 100 strings per request.
209
+
210
+ ## Configuration
211
+
212
+ Configuration is **optional**. With no config file, locale-keysmith scans **only the `src`
213
+ folder** — it looks there for locale files (`.json`, `.yml`, `.yaml`) and for source usage,
214
+ and any writes are confined to it.
23
215
 
24
- Create `locale-keysmith.config.json` in your project:
216
+ Create `locale-keysmith.config.json` in your project root to customise behaviour.
217
+
218
+ ### Scanning other folders
219
+
220
+ The simplest knob is `roots` — the folders to scan for both locale files and source usage:
221
+
222
+ ```json
223
+ {
224
+ "roots": ["src", "public/locales", "packages/ui"]
225
+ }
226
+ ```
227
+
228
+ `translationFiles` and `src` are derived from `roots` automatically. For full control you can
229
+ set either explicitly, which overrides the derived globs:
25
230
 
26
231
  ```json
27
232
  {
28
233
  "sourceLocale": "en",
29
- "translationFiles": [
30
- "src/locales/*.{json,yml,yaml}",
31
- "public/locales/**/*.{json,yml,yaml}"
32
- ],
234
+ "roots": ["src"],
235
+ "translationFiles": ["src/locales/*.{json,yml,yaml}", "public/locales/**/*.{json,yml,yaml}"],
33
236
  "src": ["src/**/*.{ts,tsx,js,jsx,vue}"],
34
237
  "ignoreKeys": ["debug.*"]
35
238
  }
36
239
  ```
37
240
 
38
- ## Google Translate
241
+ ### Fields and defaults
39
242
 
40
- Set a Google Translate API key before running the `translate` command:
243
+ | Field | Default | Purpose |
244
+ | ------------------ | --------------------------------------------------------- | ----------------------------------------------------- |
245
+ | `sourceLocale` | `"en"` | Locale treated as the source of truth. |
246
+ | `roots` | `["src"]` | Folders to scan for locale files and source usage. |
247
+ | `translationFiles` | `<root>/**/*.{json,yml,yaml}` per root | Globs for locale files (overrides the derived globs). |
248
+ | `src` | `<root>/**/*.{ts,tsx,js,jsx,mjs,cjs,vue,svelte}` per root | Globs for source files (overrides the derived globs). |
249
+ | `ignoreKeys` | `[]` | Key patterns excluded from audits (`*` wildcard). |
41
250
 
42
- ```bash
43
- export GOOGLE_TRANSLATE_API_KEY="your-api-key"
44
- pnpm exec locale-keysmith translate --from en --to de --write
251
+ The config is checked before any command runs. Wrong types (`"roots": "src"` instead of
252
+ `["src"]`), a `sourceLocale` that is not a locale code, and unknown fields (with a "did you
253
+ mean" hint for typos) are all reported together.
254
+
255
+ `node_modules`, `dist`, and `.next` are always ignored.
256
+
257
+ ### How locale files are recognised
258
+
259
+ A matched file is only treated as a locale file when its name or its directory is a locale
260
+ code, so config files such as `package.json` or `src/data/config.json` are never read or
261
+ rewritten:
262
+
263
+ | Path | Locale | Notes |
264
+ | ------------------------------- | ------- | --------------------------------------- |
265
+ | `src/locales/en.json` | `en` | from the file name |
266
+ | `config/locales/pt-BR.yml` | `pt-BR` | `pt_BR`, `zh-Hant`, `es-419` work too |
267
+ | `public/locales/de/common.json` | `de` | from the directory (i18next namespaces) |
268
+ | `src/data/config.json` | — | skipped: not a locale file |
269
+
270
+ Files are compared only with their own translations: `app/locales/de.json` with
271
+ `app/locales/en.json`, `public/locales/de/common.json` with `public/locales/en/common.json`.
272
+ That lets one config cover several independent sets of locale files (an app and a plugin, or
273
+ several namespaces). Two files for the same locale in one set (say `en.json` and `en.yaml`
274
+ side by side) are reported as an error.
275
+
276
+ ### Key usage detection
277
+
278
+ `unused`, `remove-unused`, and `health` treat a key as used whether it is passed directly or
279
+ referenced indirectly. All of these are detected:
280
+
281
+ ```ts
282
+ t("app.title"); // direct call (also i18n.t / $t / translate)
283
+ <Trans i18nKey="banner.welcome" />; // JSX i18nKey prop
284
+ t(online ? "status.online" : "status.offline"); // ternary branches
285
+
286
+ const priorityKey = { low: "priority.low", high: "priority.high" };
287
+ t(priorityKey[level]); // value from a lookup object
288
+
289
+ const tagKeys = ["tag.work", "tag.urgent"]; // keys in an array
290
+ const FOOTER = "footer.copyright"; // key in a constant
291
+ ```
292
+
293
+ Any string literal shaped like a dotted key path (e.g. `"a.b.c"`) is counted as used, including
294
+ one that only appears in a comment. Keys are also matched the way i18next resolves them at
295
+ runtime:
296
+
297
+ ```ts
298
+ t("cart.item", { count }); // cart.item_one, cart.item_other, cart.item_zero, ... are used
299
+ t("friend.greeting", { context }); // friend.greeting_male, friend.greeting_female, ... are used
300
+ t("common:common.title"); // namespaced: common.title is used
45
301
  ```
46
302
 
47
- ## Publish
303
+ A **dynamically built** key cannot be resolved statically, so every key under its static
304
+ prefix is treated as used. That is never reported or removed:
305
+
306
+ ```ts
307
+ t(`theme.${mode}`); // every key under theme. (theme.dark, theme.light, ...) is used
308
+ t("errors." + code); // every key under errors. is used
309
+ ```
48
310
 
49
- Validate without publishing:
311
+ ## Development
50
312
 
51
313
  ```bash
52
- pnpm run check
53
- pnpm publish --dry-run --access public --no-git-checks
314
+ pnpm run lint # ESLint (typescript-eslint, flat config)
315
+ pnpm run format # Prettier --write
316
+ pnpm run test # Vitest
317
+ pnpm run coverage # Vitest with v8 coverage
318
+ pnpm run check # lint + format:check + build + test
54
319
  ```
55
320
 
56
- Publish from a clean `main` branch:
321
+ `pnpm run test` never calls Google Translate. To check `translate` against the real API
322
+ (placeholders, HTML entities, batching, error messages), run the live tests with a key. A
323
+ full run sends about 2,000 characters:
57
324
 
58
325
  ```bash
59
- pnpm publish --access public
326
+ GOOGLE_TRANSLATE_API_KEY="your-api-key" pnpm run test:live
60
327
  ```
@@ -0,0 +1,30 @@
1
+ import type { LocaleFile, LocaleObject } from "./types.js";
2
+ export interface TypeMismatch {
3
+ key: string;
4
+ /** Value kind in the source file: string, number, boolean, null, array or object. */
5
+ source: string;
6
+ target: string;
7
+ }
8
+ /**
9
+ * The keys a target locale should contain: the source keys, with plural forms adjusted to
10
+ * the target language. English `item_one`/`item_other` becomes `item_one`/`item_few`/
11
+ * `item_many`/`item_other` for Polish and just `item_other` for Japanese.
12
+ */
13
+ export declare function expectedKeys(sourceKeys: string[], targetLocale: string): string[];
14
+ export declare function missingKeys(sourceKeys: string[], target: LocaleFile): string[];
15
+ /** Keys in the target that the source does not have (allowing for the target's plural forms). */
16
+ export declare function extraKeys(sourceKeys: string[], target: LocaleFile): string[];
17
+ /**
18
+ * Keys written more than once in a file. `{ "a.b": "x", "a": { "b": "y" } }` defines `a.b`
19
+ * twice, and i18next only ever reads one of the two values.
20
+ */
21
+ export declare function duplicateKeys(file: LocaleFile): string[];
22
+ /** Keys whose value is an empty or whitespace-only string, or null. */
23
+ export declare function emptyValueKeys(file: LocaleFile): string[];
24
+ /** Keys that hold a different kind of value in the target than in the source. */
25
+ export declare function typeMismatches(source: LocaleObject, target: LocaleObject, prefix?: string): TypeMismatch[];
26
+ /**
27
+ * For a plural form the source language does not have (Polish `_few` from English), the
28
+ * source text to translate from: the `_other` form, which i18next treats as the general one.
29
+ */
30
+ export declare function pluralFallbackKey(key: string): string | undefined;
package/dist/checks.js ADDED
@@ -0,0 +1,130 @@
1
+ import { flattenKeys } from "./keys.js";
2
+ // i18next plural keys: `item_one`, `item_other`, and ordinals like `place_ordinal_two`.
3
+ const pluralKey = /^(.+?)_(ordinal_)?(zero|one|two|few|many|other)$/;
4
+ const pluralCategories = ["zero", "one", "two", "few", "many", "other"];
5
+ /**
6
+ * The keys a target locale should contain: the source keys, with plural forms adjusted to
7
+ * the target language. English `item_one`/`item_other` becomes `item_one`/`item_few`/
8
+ * `item_many`/`item_other` for Polish and just `item_other` for Japanese.
9
+ */
10
+ export function expectedKeys(sourceKeys, targetLocale) {
11
+ const available = new Set(sourceKeys);
12
+ const expanded = new Set();
13
+ const expected = [];
14
+ for (const key of sourceKeys) {
15
+ const plural = parsePluralKey(key, available);
16
+ if (!plural) {
17
+ expected.push(key);
18
+ continue;
19
+ }
20
+ if (expanded.has(plural.stem)) {
21
+ continue;
22
+ }
23
+ expanded.add(plural.stem);
24
+ // `_zero` is optional in i18next, so it is only expected when the source has one.
25
+ const categories = categoriesFor(targetLocale, plural.ordinal);
26
+ const wanted = pluralCategories.filter((category) => categories.has(category) || (category === "zero" && available.has(`${plural.stem}zero`)));
27
+ expected.push(...wanted.map((category) => `${plural.stem}${category}`));
28
+ }
29
+ return expected;
30
+ }
31
+ export function missingKeys(sourceKeys, target) {
32
+ const present = new Set(flattenKeys(target.data));
33
+ return expectedKeys(sourceKeys, target.locale).filter((key) => !present.has(key));
34
+ }
35
+ /** Keys in the target that the source does not have (allowing for the target's plural forms). */
36
+ export function extraKeys(sourceKeys, target) {
37
+ const expected = new Set(expectedKeys(sourceKeys, target.locale));
38
+ const available = new Set(sourceKeys);
39
+ return flattenKeys(target.data).filter((key) => {
40
+ if (expected.has(key)) {
41
+ return false;
42
+ }
43
+ // An optional `_zero` form is fine wherever the base key is a plural.
44
+ const plural = pluralKey.exec(key);
45
+ return !(plural?.[3] === "zero" && available.has(`${plural[1]}_${plural[2] ?? ""}other`));
46
+ });
47
+ }
48
+ /**
49
+ * Keys written more than once in a file. `{ "a.b": "x", "a": { "b": "y" } }` defines `a.b`
50
+ * twice, and i18next only ever reads one of the two values.
51
+ */
52
+ export function duplicateKeys(file) {
53
+ const seen = new Set();
54
+ const duplicates = new Set();
55
+ for (const [key] of leafEntries(file.data)) {
56
+ (seen.has(key) ? duplicates : seen).add(key);
57
+ }
58
+ return [...duplicates];
59
+ }
60
+ /** Keys whose value is an empty or whitespace-only string, or null. */
61
+ export function emptyValueKeys(file) {
62
+ return leafEntries(file.data)
63
+ .filter(([, value]) => value === null || (typeof value === "string" && value.trim() === ""))
64
+ .map(([key]) => key);
65
+ }
66
+ /** Keys that hold a different kind of value in the target than in the source. */
67
+ export function typeMismatches(source, target, prefix = "") {
68
+ return Object.entries(source).flatMap(([key, sourceValue]) => {
69
+ if (!Object.hasOwn(target, key)) {
70
+ return [];
71
+ }
72
+ const path = prefix ? `${prefix}.${key}` : key;
73
+ const targetValue = target[key];
74
+ const sourceKind = kindOf(sourceValue);
75
+ const targetKind = kindOf(targetValue);
76
+ if (sourceKind !== targetKind) {
77
+ return [{ key: path, source: sourceKind, target: targetKind }];
78
+ }
79
+ return sourceKind === "object"
80
+ ? typeMismatches(sourceValue, targetValue, path)
81
+ : [];
82
+ });
83
+ }
84
+ /**
85
+ * For a plural form the source language does not have (Polish `_few` from English), the
86
+ * source text to translate from: the `_other` form, which i18next treats as the general one.
87
+ */
88
+ export function pluralFallbackKey(key) {
89
+ const plural = pluralKey.exec(key);
90
+ return plural && plural[3] !== "other" ? `${plural[1]}_${plural[2] ?? ""}other` : undefined;
91
+ }
92
+ function parsePluralKey(key, available) {
93
+ const match = pluralKey.exec(key);
94
+ if (!match) {
95
+ return undefined;
96
+ }
97
+ const stem = `${match[1]}_${match[2] ?? ""}`;
98
+ // Only treat it as a plural when the group has the mandatory `_other` form; a key like
99
+ // `step_one` on its own is just a name.
100
+ return available.has(`${stem}other`) ? { stem, ordinal: Boolean(match[2]) } : undefined;
101
+ }
102
+ function categoriesFor(locale, ordinal) {
103
+ const tag = locale.replaceAll("_", "-");
104
+ const type = ordinal ? "ordinal" : "cardinal";
105
+ try {
106
+ if (Intl.PluralRules.supportedLocalesOf(tag).length > 0) {
107
+ return new Set(new Intl.PluralRules(tag, { type }).resolvedOptions().pluralCategories);
108
+ }
109
+ }
110
+ catch {
111
+ // Not a valid tag: fall through and keep every form.
112
+ }
113
+ return new Set(pluralCategories);
114
+ }
115
+ function leafEntries(value, prefix = "") {
116
+ return Object.entries(value).flatMap(([key, child]) => {
117
+ const path = prefix ? `${prefix}.${key}` : key;
118
+ return kindOf(child) === "object" ? leafEntries(child, path) : [[path, child]];
119
+ });
120
+ }
121
+ function kindOf(value) {
122
+ if (value === null) {
123
+ return "null";
124
+ }
125
+ if (Array.isArray(value)) {
126
+ return "array";
127
+ }
128
+ return typeof value;
129
+ }
130
+ //# sourceMappingURL=checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.js","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,wFAAwF;AACxF,MAAM,SAAS,GAAG,kDAAkD,CAAC;AACrE,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AASxE;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAoB,EAAE,YAAoB;IACrE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAE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