@jjlmoya/utils-textiles 1.20.0 → 1.22.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/package.json +1 -1
- package/src/category/i18n/de.ts +76 -76
- package/src/category/i18n/en.ts +76 -76
- package/src/category/i18n/es.ts +76 -76
- package/src/category/i18n/fr.ts +76 -76
- package/src/category/i18n/id.ts +76 -76
- package/src/category/i18n/it.ts +76 -76
- package/src/category/i18n/ja.ts +76 -76
- package/src/category/i18n/ko.ts +76 -76
- package/src/category/i18n/nl.ts +76 -76
- package/src/category/i18n/pl.ts +76 -76
- package/src/category/i18n/pt.ts +76 -76
- package/src/category/i18n/ru.ts +76 -76
- package/src/category/i18n/sv.ts +76 -76
- package/src/category/i18n/zh.ts +76 -76
- package/src/category/index.ts +2 -0
- package/src/category/seo.astro +1 -1
- package/src/components/PreviewNavSidebar.astro +1 -1
- package/src/components/PreviewToolbar.astro +1 -1
- package/src/data.ts +1 -1
- package/src/entries.ts +4 -1
- package/src/env.d.ts +1 -1
- package/src/index.ts +1 -1
- package/src/layouts/PreviewLayout.astro +113 -113
- package/src/pages/index.astro +1 -1
- package/src/tests/faq_count.test.ts +19 -19
- package/src/tests/i18n_coverage.test.ts +4 -2
- package/src/tests/locale_spelling.test.ts +44 -0
- package/src/tests/mocks/astro_mock.js +1 -1
- package/src/tests/no_en_dash.test.ts +70 -70
- package/src/tests/no_h1_in_components.test.ts +1 -1
- package/src/tests/seo_length.test.ts +22 -22
- package/src/tests/seo_translation_completeness.test.ts +69 -0
- package/src/tests/spanish_leakage.test.ts +175 -153
- package/src/tests/tool_validation.test.ts +17 -17
- package/src/tool/burnTest/i18n/es.ts +211 -211
- package/src/tool/burnTest/i18n/fr.ts +211 -211
- package/src/tool/burnTest/i18n/ja.ts +211 -211
- package/src/tool/burnTest/i18n/ko.ts +211 -211
- package/src/tool/burnTest/i18n/pl.ts +211 -211
- package/src/tool/burnTest/i18n/ru.ts +211 -211
- package/src/tool/burnTest/i18n/sv.ts +211 -211
- package/src/tool/burnTest/i18n/zh.ts +211 -211
- package/src/tool/burnTest/seo.astro +15 -15
- package/src/tool/clothingSizeConverter/i18n/de.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/en.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/fr.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/ja.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/ko.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/nl.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/pl.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/ru.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/sv.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/tr.ts +348 -348
- package/src/tool/clothingSizeConverter/i18n/zh.ts +348 -348
- package/src/tool/clothingSizeConverter/seo.astro +15 -15
- package/src/tool/embroideryStitchPricingEstimator/bibliography.astro +6 -0
- package/src/tool/embroideryStitchPricingEstimator/bibliography.ts +12 -0
- package/src/tool/embroideryStitchPricingEstimator/component.astro +111 -0
- package/src/tool/embroideryStitchPricingEstimator/controller.ts +111 -0
- package/src/tool/embroideryStitchPricingEstimator/dom-views.ts +94 -0
- package/src/tool/embroideryStitchPricingEstimator/embroidery-stitch-count-pricing-estimator.css +438 -0
- package/src/tool/embroideryStitchPricingEstimator/entry.ts +29 -0
- package/src/tool/embroideryStitchPricingEstimator/evaluator.ts +22 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/de.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/en.ts +194 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/es.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/fr.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/id.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/it.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/ja.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/ko.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/nl.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/pl.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/pt.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/ru.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/sv.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/tr.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/i18n/zh.ts +38 -0
- package/src/tool/embroideryStitchPricingEstimator/index.ts +11 -0
- package/src/tool/embroideryStitchPricingEstimator/logic.test.ts +40 -0
- package/src/tool/embroideryStitchPricingEstimator/logic.ts +86 -0
- package/src/tool/embroideryStitchPricingEstimator/seo.astro +15 -0
- package/src/tool/embroideryStitchPricingEstimator/storage.ts +20 -0
- package/src/tool/embroideryStitchPricingEstimator/ui.ts +53 -0
- package/src/tool/fabricProjectCalculator/i18n/de.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/ja.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/ko.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/nl.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/pl.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/ru.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/sv.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/tr.ts +236 -236
- package/src/tool/fabricProjectCalculator/i18n/zh.ts +236 -236
- package/src/tool/fabricProjectCalculator/seo.astro +15 -15
- package/src/tool/fabricTruth/i18n/de.ts +268 -268
- package/src/tool/fabricTruth/i18n/en.ts +268 -268
- package/src/tool/fabricTruth/i18n/es.ts +302 -302
- package/src/tool/fabricTruth/i18n/fr.ts +268 -268
- package/src/tool/fabricTruth/i18n/id.ts +268 -268
- package/src/tool/fabricTruth/i18n/it.ts +268 -268
- package/src/tool/fabricTruth/i18n/ja.ts +268 -268
- package/src/tool/fabricTruth/i18n/ko.ts +268 -268
- package/src/tool/fabricTruth/i18n/nl.ts +268 -268
- package/src/tool/fabricTruth/i18n/pl.ts +268 -268
- package/src/tool/fabricTruth/i18n/pt.ts +268 -268
- package/src/tool/fabricTruth/i18n/ru.ts +268 -268
- package/src/tool/fabricTruth/i18n/sv.ts +268 -268
- package/src/tool/fabricTruth/i18n/tr.ts +268 -268
- package/src/tool/fabricTruth/i18n/zh.ts +272 -272
- package/src/tool/fabricTruth/seo.astro +15 -15
- package/src/tool/fiberPrep/i18n/de.ts +215 -215
- package/src/tool/fiberPrep/i18n/fr.ts +215 -215
- package/src/tool/fiberPrep/i18n/ja.ts +215 -215
- package/src/tool/fiberPrep/i18n/ko.ts +215 -215
- package/src/tool/fiberPrep/i18n/nl.ts +215 -215
- package/src/tool/fiberPrep/i18n/pl.ts +215 -215
- package/src/tool/fiberPrep/i18n/ru.ts +215 -215
- package/src/tool/fiberPrep/i18n/sv.ts +215 -215
- package/src/tool/fiberPrep/i18n/tr.ts +215 -215
- package/src/tool/fiberPrep/i18n/zh.ts +215 -215
- package/src/tool/fiberPrep/seo.astro +15 -15
- package/src/tool/knittingGauge/i18n/de.ts +224 -224
- package/src/tool/knittingGauge/i18n/ja.ts +224 -224
- package/src/tool/knittingGauge/i18n/ko.ts +224 -224
- package/src/tool/knittingGauge/i18n/pl.ts +224 -224
- package/src/tool/knittingGauge/i18n/ru.ts +224 -224
- package/src/tool/knittingGauge/i18n/tr.ts +224 -224
- package/src/tool/knittingGauge/i18n/zh.ts +224 -224
- package/src/tool/knittingGauge/seo.astro +15 -15
- package/src/tool/laundryGuide/i18n/de.ts +271 -271
- package/src/tool/laundryGuide/i18n/en.ts +271 -271
- package/src/tool/laundryGuide/i18n/es.ts +271 -271
- package/src/tool/laundryGuide/i18n/fr.ts +255 -255
- package/src/tool/laundryGuide/i18n/id.ts +271 -271
- package/src/tool/laundryGuide/i18n/it.ts +271 -271
- package/src/tool/laundryGuide/i18n/ja.ts +271 -271
- package/src/tool/laundryGuide/i18n/ko.ts +271 -271
- package/src/tool/laundryGuide/i18n/nl.ts +271 -271
- package/src/tool/laundryGuide/i18n/pl.ts +271 -271
- package/src/tool/laundryGuide/i18n/pt.ts +271 -271
- package/src/tool/laundryGuide/i18n/ru.ts +271 -271
- package/src/tool/laundryGuide/i18n/sv.ts +271 -271
- package/src/tool/laundryGuide/i18n/tr.ts +271 -271
- package/src/tool/laundryGuide/i18n/zh.ts +271 -271
- package/src/tool/laundryGuide/seo.astro +15 -15
- package/src/tool/needleConverter/i18n/de.ts +202 -202
- package/src/tool/needleConverter/i18n/es.ts +207 -207
- package/src/tool/needleConverter/i18n/fr.ts +207 -207
- package/src/tool/needleConverter/i18n/ja.ts +202 -202
- package/src/tool/needleConverter/i18n/ko.ts +202 -202
- package/src/tool/needleConverter/i18n/nl.ts +202 -202
- package/src/tool/needleConverter/i18n/pl.ts +202 -202
- package/src/tool/needleConverter/i18n/ru.ts +202 -202
- package/src/tool/needleConverter/i18n/sv.ts +202 -202
- package/src/tool/needleConverter/i18n/tr.ts +202 -202
- package/src/tool/needleConverter/i18n/zh.ts +202 -202
- package/src/tool/needleConverter/seo.astro +15 -15
- package/src/tool/sewingPatternScaler/component.astro +236 -236
- package/src/tool/sewingPatternScaler/i18n/fr.ts +170 -170
- package/src/tool/sewingPatternScaler/i18n/ja.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/ko.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/nl.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/pl.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/ru.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/sv.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/tr.ts +114 -114
- package/src/tool/sewingPatternScaler/i18n/zh.ts +114 -114
- package/src/tool/sewingPatternScaler/seo.astro +15 -15
- package/src/tool/shoeSizeConverter/i18n/fr.ts +183 -183
- package/src/tool/shoeSizeConverter/i18n/ja.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/ko.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/nl.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/pl.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/ru.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/sv.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/tr.ts +179 -179
- package/src/tool/shoeSizeConverter/i18n/zh.ts +179 -179
- package/src/tool/shoeSizeConverter/seo.astro +15 -15
- package/src/tool/stainChemistry/bibliography.ts +16 -16
- package/src/tool/stainChemistry/i18n/de.ts +286 -286
- package/src/tool/stainChemistry/i18n/en.ts +289 -289
- package/src/tool/stainChemistry/i18n/es.ts +286 -286
- package/src/tool/stainChemistry/i18n/fr.ts +296 -296
- package/src/tool/stainChemistry/i18n/id.ts +286 -286
- package/src/tool/stainChemistry/i18n/it.ts +286 -286
- package/src/tool/stainChemistry/i18n/ja.ts +286 -286
- package/src/tool/stainChemistry/i18n/ko.ts +283 -283
- package/src/tool/stainChemistry/i18n/nl.ts +286 -286
- package/src/tool/stainChemistry/i18n/pl.ts +286 -286
- package/src/tool/stainChemistry/i18n/pt.ts +286 -286
- package/src/tool/stainChemistry/i18n/ru.ts +286 -286
- package/src/tool/stainChemistry/i18n/sv.ts +286 -286
- package/src/tool/stainChemistry/i18n/tr.ts +286 -286
- package/src/tool/stainChemistry/i18n/zh.ts +281 -281
- package/src/tool/stainChemistry/seo.astro +15 -15
- package/src/tool/yarnCalculator/i18n/de.ts +296 -296
- package/src/tool/yarnCalculator/i18n/es.ts +296 -296
- package/src/tool/yarnCalculator/i18n/fr.ts +296 -296
- package/src/tool/yarnCalculator/i18n/ja.ts +296 -296
- package/src/tool/yarnCalculator/i18n/ko.ts +296 -296
- package/src/tool/yarnCalculator/i18n/nl.ts +296 -296
- package/src/tool/yarnCalculator/i18n/pl.ts +296 -296
- package/src/tool/yarnCalculator/i18n/ru.ts +296 -296
- package/src/tool/yarnCalculator/i18n/sv.ts +296 -296
- package/src/tool/yarnCalculator/i18n/tr.ts +296 -296
- package/src/tool/yarnCalculator/i18n/zh.ts +295 -295
- package/src/tool/yarnCalculator/seo.astro +15 -15
- package/src/tools.ts +2 -2
|
@@ -1,153 +1,175 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { ALL_ENTRIES } from '../entries';
|
|
3
|
-
|
|
4
|
-
const STRUCTURAL_KEYS = new Set([
|
|
5
|
-
'id',
|
|
6
|
-
'slug',
|
|
7
|
-
'url',
|
|
8
|
-
'icon',
|
|
9
|
-
'image',
|
|
10
|
-
'imageUrl',
|
|
11
|
-
'keywords',
|
|
12
|
-
'category',
|
|
13
|
-
'tags',
|
|
14
|
-
'toolId',
|
|
15
|
-
'type',
|
|
16
|
-
'locale',
|
|
17
|
-
'language',
|
|
18
|
-
'direction',
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
const TRANSLATABLE_KEYS = [
|
|
22
|
-
'title',
|
|
23
|
-
'description',
|
|
24
|
-
'faqTitle',
|
|
25
|
-
'faq',
|
|
26
|
-
'howTo',
|
|
27
|
-
'seo',
|
|
28
|
-
'schemas',
|
|
29
|
-
] as const;
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
['
|
|
35
|
-
['
|
|
36
|
-
['
|
|
37
|
-
['
|
|
38
|
-
['
|
|
39
|
-
['
|
|
40
|
-
['
|
|
41
|
-
['
|
|
42
|
-
['
|
|
43
|
-
['
|
|
44
|
-
['
|
|
45
|
-
['
|
|
46
|
-
['
|
|
47
|
-
['
|
|
48
|
-
['
|
|
49
|
-
['
|
|
50
|
-
['
|
|
51
|
-
['
|
|
52
|
-
['
|
|
53
|
-
['
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.replace(
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (typeof
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ALL_ENTRIES } from '../entries';
|
|
3
|
+
|
|
4
|
+
const STRUCTURAL_KEYS = new Set([
|
|
5
|
+
'id',
|
|
6
|
+
'slug',
|
|
7
|
+
'url',
|
|
8
|
+
'icon',
|
|
9
|
+
'image',
|
|
10
|
+
'imageUrl',
|
|
11
|
+
'keywords',
|
|
12
|
+
'category',
|
|
13
|
+
'tags',
|
|
14
|
+
'toolId',
|
|
15
|
+
'type',
|
|
16
|
+
'locale',
|
|
17
|
+
'language',
|
|
18
|
+
'direction',
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const TRANSLATABLE_KEYS = [
|
|
22
|
+
'title',
|
|
23
|
+
'description',
|
|
24
|
+
'faqTitle',
|
|
25
|
+
'faq',
|
|
26
|
+
'howTo',
|
|
27
|
+
'seo',
|
|
28
|
+
'schemas',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
const COPY_THRESHOLD = 0.9;
|
|
32
|
+
|
|
33
|
+
const SPANISH_MARKERS = [
|
|
34
|
+
['sangre', /\bsangre\b/gi],
|
|
35
|
+
['molino', /\bmolino\b/gi],
|
|
36
|
+
['grano', /\bgrano\b/gi],
|
|
37
|
+
['paladar', /\bpaladar\b/gi],
|
|
38
|
+
['cuchillas', /\bcuchillas\b/gi],
|
|
39
|
+
['trozos', /\btrozos\b/gi],
|
|
40
|
+
['frescura', /\bfrescura\b/gi],
|
|
41
|
+
['ingresa', /\bingresa\b/gi],
|
|
42
|
+
['selecciona', /\bselecciona\b/gi],
|
|
43
|
+
['herramienta', /\bherramienta\b/gi],
|
|
44
|
+
['según', /\bsegún\b/gi],
|
|
45
|
+
['después', /\bdespués\b/gi],
|
|
46
|
+
['puedes', /\bpuedes\b/gi],
|
|
47
|
+
['debes', /\bdebes\b/gi],
|
|
48
|
+
['tus', /\btus\b/gi],
|
|
49
|
+
['a la vez', /\ba la vez\b/gi],
|
|
50
|
+
['los datos', /\blos datos\b/gi],
|
|
51
|
+
['las opciones', /\blas opciones\b/gi],
|
|
52
|
+
['el resultado', /\bel resultado\b/gi],
|
|
53
|
+
['método de extracción', /\bmétodo de extracción\b/gi],
|
|
54
|
+
['uniformidad del molino', /\buniformidad del molino\b/gi],
|
|
55
|
+
['café recién tostado', /\bcafé recién tostado\b/gi],
|
|
56
|
+
] as const;
|
|
57
|
+
|
|
58
|
+
type UnknownRecord = Record<string, unknown>;
|
|
59
|
+
|
|
60
|
+
function normalize(value: string): string {
|
|
61
|
+
return value
|
|
62
|
+
.replace(/<[^>]*>/g, ' ')
|
|
63
|
+
.replace(/ /gi, ' ')
|
|
64
|
+
.replace(/\s+/g, ' ')
|
|
65
|
+
.trim()
|
|
66
|
+
.toLocaleLowerCase('es');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isTechnicalInvariant(text: string): boolean {
|
|
70
|
+
const ledUnitMatches = text.match(/\b\d+(?:-\d+)?\s*(?:w|lm)\b/g) ?? [];
|
|
71
|
+
return [
|
|
72
|
+
'data:image/svg+xml;base64',
|
|
73
|
+
'background-image: url',
|
|
74
|
+
'.layout-playground {',
|
|
75
|
+
'const samplerate =',
|
|
76
|
+
].some((pattern) => text.includes(pattern)) ||
|
|
77
|
+
(text.includes('presets') && text.includes('hz')) ||
|
|
78
|
+
(text.includes('t_rectal') && text.includes('exp(-k * t)')) ||
|
|
79
|
+
(text.includes('led') && ledUnitMatches.length >= 3);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function collectString(value: string, output: string[]): void {
|
|
83
|
+
const text = normalize(value);
|
|
84
|
+
if (!isTechnicalInvariant(text) && text.length >= 20) output.push(text);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function collectObject(value: UnknownRecord, output: string[]): void {
|
|
88
|
+
Object.entries(value).forEach(([childKey, childValue]) => {
|
|
89
|
+
collectText(childValue, output, childKey);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function collectText(value: unknown, output: string[], key?: string): void {
|
|
94
|
+
if (key && STRUCTURAL_KEYS.has(key)) return;
|
|
95
|
+
if (typeof value === 'string') return collectString(value, output);
|
|
96
|
+
if (Array.isArray(value)) return value.forEach((item) => collectText(item, output));
|
|
97
|
+
if (value && typeof value === 'object') collectObject(value as UnknownRecord, output);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function loadText(loader: unknown): Promise<string[]> {
|
|
101
|
+
if (typeof loader !== 'function') return [];
|
|
102
|
+
const module = await (loader as () => Promise<unknown>)();
|
|
103
|
+
const output: string[] = [];
|
|
104
|
+
if (module && typeof module === 'object') {
|
|
105
|
+
const record = module as UnknownRecord;
|
|
106
|
+
for (const key of TRANSLATABLE_KEYS) {
|
|
107
|
+
collectText(record[key], output, key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function findSpanishMarkers(text: string[]): string[] {
|
|
114
|
+
const corpus = text.join(' ');
|
|
115
|
+
return SPANISH_MARKERS.flatMap(([label, pattern]) =>
|
|
116
|
+
pattern.test(corpus) ? [label] : [],
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function similarity(left: string, right: string): number {
|
|
121
|
+
const leftTokens = left.split(/\s+/);
|
|
122
|
+
const rightCounts = new Map<string, number>();
|
|
123
|
+
right.split(/\s+/).forEach((token) => rightCounts.set(token, (rightCounts.get(token) ?? 0) + 1));
|
|
124
|
+
const matches = leftTokens.reduce((total, token) => {
|
|
125
|
+
const count = rightCounts.get(token) ?? 0;
|
|
126
|
+
if (count > 0) rightCounts.set(token, count - 1);
|
|
127
|
+
return total + (count > 0 ? 1 : 0);
|
|
128
|
+
}, 0);
|
|
129
|
+
return (2 * matches) / (leftTokens.length + right.split(/\s+/).length);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function findCopiedFragments(spanish: string[], translated: string[]): string[] {
|
|
133
|
+
return spanish
|
|
134
|
+
.filter((fragment) => fragment.length >= 80)
|
|
135
|
+
.filter((fragment) => translated.some((candidate) =>
|
|
136
|
+
candidate.length >= 80 &&
|
|
137
|
+
Math.min(fragment.length, candidate.length) / Math.max(fragment.length, candidate.length) >= COPY_THRESHOLD &&
|
|
138
|
+
similarity(fragment, candidate) >= COPY_THRESHOLD,
|
|
139
|
+
))
|
|
140
|
+
.sort((a, b) => b.length - a.length)
|
|
141
|
+
.slice(0, 3);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
describe('Locales must not contain copied Spanish content', () => {
|
|
145
|
+
for (const entry of ALL_ENTRIES) {
|
|
146
|
+
it(`${entry.id} has no untranslated Spanish blocks`, async () => {
|
|
147
|
+
const spanish = await loadText(entry.i18n.es);
|
|
148
|
+
const failures: string[] = [];
|
|
149
|
+
|
|
150
|
+
for (const [locale, loader] of Object.entries(entry.i18n)) {
|
|
151
|
+
if (locale === 'es') continue;
|
|
152
|
+
|
|
153
|
+
const translated = await loadText(loader);
|
|
154
|
+
const copiedFragments = findCopiedFragments(spanish, translated);
|
|
155
|
+
const markerHits = findSpanishMarkers(translated);
|
|
156
|
+
|
|
157
|
+
if (copiedFragments.length > 0 || markerHits.length >= 2) {
|
|
158
|
+
const details = [
|
|
159
|
+
copiedFragments.length > 0
|
|
160
|
+
? `copied fragments: ${copiedFragments
|
|
161
|
+
.map((fragment) => JSON.stringify(fragment.slice(0, 120)))
|
|
162
|
+
.join(', ')}`
|
|
163
|
+
: '',
|
|
164
|
+
markerHits.length >= 2 ? `Spanish markers: ${markerHits.join(', ')}` : '',
|
|
165
|
+
]
|
|
166
|
+
.filter(Boolean)
|
|
167
|
+
.join('; ');
|
|
168
|
+
failures.push(`${locale}: ${details}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
expect(failures, failures.join('\n')).toEqual([]);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { ALL_TOOLS } from '../tools';
|
|
3
|
-
import { textilesCategory } from '../data';
|
|
4
|
-
|
|
5
|
-
describe('Tool Validation Suite', () => {
|
|
6
|
-
describe('Library Registration', () => {
|
|
7
|
-
it('should have
|
|
8
|
-
expect(ALL_TOOLS.length).toBe(
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('textilesCategory should be defined', () => {
|
|
12
|
-
expect(textilesCategory).toBeDefined();
|
|
13
|
-
expect(textilesCategory.i18n).toBeDefined();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
import { textilesCategory } from '../data';
|
|
4
|
+
|
|
5
|
+
describe('Tool Validation Suite', () => {
|
|
6
|
+
describe('Library Registration', () => {
|
|
7
|
+
it('should have 13 tools in ALL_TOOLS', () => {
|
|
8
|
+
expect(ALL_TOOLS.length).toBe(13);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('textilesCategory should be defined', () => {
|
|
12
|
+
expect(textilesCategory).toBeDefined();
|
|
13
|
+
expect(textilesCategory.i18n).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|