@jjlmoya/utils-home 1.35.0 → 1.37.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.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/scripts/fix_ru.mjs +79 -0
  3. package/src/entries.ts +4 -1
  4. package/src/index.ts +1 -0
  5. package/src/layouts/PreviewLayout.astro +1 -0
  6. package/src/tests/diacritics_density.test.ts +118 -0
  7. package/src/tests/inverted_punctuation.test.ts +84 -0
  8. package/src/tests/locale_completeness.test.ts +2 -2
  9. package/src/tests/script_density.test.ts +94 -0
  10. package/src/tests/tool_validation.test.ts +2 -2
  11. package/src/tool/applianceCostCalculator/i18n/pl.ts +53 -53
  12. package/src/tool/applianceCostCalculator/i18n/pt.ts +48 -48
  13. package/src/tool/heatingComparator/heating-consumption-comparator.css +89 -4
  14. package/src/tool/humidityCalculator/bibliography.ts +2 -2
  15. package/src/tool/humidityCalculator/i18n/sv.ts +57 -57
  16. package/src/tool/projectorCalculator/i18n/es.ts +1 -1
  17. package/src/tool/tileLayoutCalculator/tile-layout-calculator.css +90 -5
  18. package/src/tool/waterSoftener/bibliography.astro +14 -0
  19. package/src/tool/waterSoftener/bibliography.ts +14 -0
  20. package/src/tool/waterSoftener/component.astro +321 -0
  21. package/src/tool/waterSoftener/entry.ts +29 -0
  22. package/src/tool/waterSoftener/i18n/de.ts +222 -0
  23. package/src/tool/waterSoftener/i18n/en.ts +222 -0
  24. package/src/tool/waterSoftener/i18n/es.ts +222 -0
  25. package/src/tool/waterSoftener/i18n/fr.ts +222 -0
  26. package/src/tool/waterSoftener/i18n/id.ts +222 -0
  27. package/src/tool/waterSoftener/i18n/it.ts +222 -0
  28. package/src/tool/waterSoftener/i18n/ja.ts +222 -0
  29. package/src/tool/waterSoftener/i18n/ko.ts +222 -0
  30. package/src/tool/waterSoftener/i18n/nl.ts +222 -0
  31. package/src/tool/waterSoftener/i18n/pl.ts +222 -0
  32. package/src/tool/waterSoftener/i18n/pt.ts +222 -0
  33. package/src/tool/waterSoftener/i18n/ru.ts +222 -0
  34. package/src/tool/waterSoftener/i18n/sv.ts +222 -0
  35. package/src/tool/waterSoftener/i18n/tr.ts +222 -0
  36. package/src/tool/waterSoftener/i18n/zh.ts +222 -0
  37. package/src/tool/waterSoftener/index.ts +9 -0
  38. package/src/tool/waterSoftener/logic.ts +103 -0
  39. package/src/tool/waterSoftener/seo.astro +15 -0
  40. package/src/tool/waterSoftener/ui.ts +34 -0
  41. package/src/tool/waterSoftener/water-softener.css +449 -0
  42. package/src/tool/wifiRangeSimulator/i18n/ru.ts +212 -212
  43. package/src/tools.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjlmoya/utils-home",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -0,0 +1,79 @@
1
+ import { readFileSync, writeFileSync } from 'fs';
2
+
3
+ function toCyrillic(text) {
4
+ let result = '';
5
+ let i = 0;
6
+
7
+ while (i < text.length) {
8
+ const c4 = text.slice(i, i + 4);
9
+ if (c4.length === 4) {
10
+ const t = { 'shch':'щ', 'SHCH':'Щ', 'Shch':'Щ' };
11
+ if (t[c4]) { result += t[c4]; i += 4; continue; }
12
+ }
13
+
14
+ if (i + 2 <= text.length) {
15
+ const two = text.slice(i, i + 2);
16
+
17
+ if (two === 'ya' || two === 'YA' || two === 'Ya') { result += ({'ya':'я','YA':'Я','Ya':'Я'})[two]; i += 2; continue; }
18
+ if (two === 'ye' || two === 'YE' || two === 'Ye') { result += ({'ye':'е','YE':'Е','Ye':'Е'})[two]; i += 2; continue; }
19
+ if (two === 'yo' || two === 'YO' || two === 'Yo') { result += ({'yo':'ё','YO':'Ё','Yo':'Ё'})[two]; i += 2; continue; }
20
+ if (two === 'yu' || two === 'YU' || two === 'Yu') { result += ({'yu':'ю','YU':'Ю','Yu':'Ю'})[two]; i += 2; continue; }
21
+
22
+ if (two === 'zh' || two === 'ZH' || two === 'Zh') { result += ({'zh':'ж','ZH':'Ж','Zh':'Ж'})[two]; i += 2; continue; }
23
+ if (two === 'ch' || two === 'CH' || two === 'Ch') { result += ({'ch':'ч','CH':'Ч','Ch':'Ч'})[two]; i += 2; continue; }
24
+ if (two === 'sh' || two === 'SH' || two === 'Sh') { result += ({'sh':'ш','SH':'Ш','Sh':'Ш'})[two]; i += 2; continue; }
25
+ if (two === 'kh' || two === 'KH' || two === 'Kh') { result += ({'kh':'х','KH':'Х','Kh':'Х'})[two]; i += 2; continue; }
26
+ if (two === 'ts' || two === 'TS' || two === 'Ts') { result += ({'ts':'ц','TS':'Ц','Ts':'Ц'})[two]; i += 2; continue; }
27
+
28
+ const next = text[i + 2] || '';
29
+ if (two === 'iy' && next !== 'a' && next !== 'e' && next !== 'o' && next !== 'u') { result += 'ий'; i += 2; continue; }
30
+ if (two === 'yy' && next !== 'a' && next !== 'e' && next !== 'o' && next !== 'u') { result += 'ый'; i += 2; continue; }
31
+ if (two === 'oy' && next !== 'a' && next !== 'e' && next !== 'o' && next !== 'u') { result += 'ой'; i += 2; continue; }
32
+ if (two === 'ay' && next !== 'a' && next !== 'e' && next !== 'o' && next !== 'u') { result += 'ай'; i += 2; continue; }
33
+ if (two === 'ey' && next !== 'a' && next !== 'e' && next !== 'o' && next !== 'u') { result += 'ей'; i += 2; continue; }
34
+ }
35
+
36
+ const c = text[i];
37
+ const smap = {
38
+ 'A':'А','a':'а','B':'Б','b':'б','V':'В','v':'в','G':'Г','g':'г',
39
+ 'D':'Д','d':'д','E':'Э','e':'е','Z':'З','z':'з','I':'И','i':'и',
40
+ 'K':'К','k':'к','L':'Л','l':'л','M':'М','m':'м','N':'Н','n':'н',
41
+ 'O':'О','o':'о','P':'П','p':'п','R':'Р','r':'р','S':'С','s':'с',
42
+ 'T':'Т','t':'т','U':'У','u':'у','F':'Ф','f':'ф','C':'Ц','c':'ц',
43
+ 'H':'Х','h':'х','Y':'Ы','y':'ы','J':'Й','j':'й',
44
+ };
45
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
46
+ result += smap[c] || c;
47
+ } else {
48
+ result += c;
49
+ }
50
+ i++;
51
+ }
52
+
53
+ result = result.replace(/WиФи/gi, 'WiFi');
54
+ result = result.replace(/Wи-Фи/gi, 'Wi-Fi');
55
+
56
+ return result;
57
+ }
58
+
59
+ function countLatin(s) {
60
+ return (s.match(/[a-zA-Z]/g) || []).length;
61
+ }
62
+
63
+ const filePath = process.argv[2];
64
+ let content = readFileSync(filePath, 'utf-8');
65
+
66
+ content = content.replace(/'([^']*)'/g, (full, text) => {
67
+ if (text.length < 5) return full;
68
+ if (/^(http|\/|\.|#|@|mdi:)/.test(text)) return full;
69
+ if (/^[0-9+\-.,%°\s]+$/.test(text)) return full;
70
+ if (/^(FAQPage|HowTo|SoftwareApplication|UtilityApplication|Question|Answer|HowToStep|Offer|schema-dts)$/.test(text)) return full;
71
+
72
+ const latin = countLatin(text);
73
+ if (latin < 5) return full;
74
+
75
+ return "'" + toCyrillic(text) + "'";
76
+ });
77
+
78
+ writeFileSync(filePath, content, 'utf-8');
79
+ console.log('Done');
package/src/entries.ts CHANGED
@@ -30,6 +30,8 @@ export { lightingCalculator } from './tool/lightingCalculator/entry';
30
30
  export type { LightingCalculatorLocaleContent } from './tool/lightingCalculator/entry';
31
31
  export { humidityCalculator } from './tool/humidityCalculator/entry';
32
32
  export type { HumidityCalculatorLocaleContent } from './tool/humidityCalculator/entry';
33
+ export { waterSoftener } from './tool/waterSoftener/entry';
34
+ export type { WaterSoftenerLocaleContent } from './tool/waterSoftener/entry';
33
35
  export { homeCategory } from './category';
34
36
  import { dewPointCalculator } from './tool/dewPointCalculator/entry';
35
37
  import { heatingComparator } from './tool/heatingComparator/entry';
@@ -47,4 +49,5 @@ import { applianceCostCalculator } from './tool/applianceCostCalculator/entry';
47
49
  import { tileLayoutCalculator } from './tool/tileLayoutCalculator/entry';
48
50
  import { lightingCalculator } from './tool/lightingCalculator/entry';
49
51
  import { humidityCalculator } from './tool/humidityCalculator/entry';
50
- export const ALL_ENTRIES = [dewPointCalculator, heatingComparator, ledSavingCalculator, projectorCalculator, qrGenerator, solarCalculator, tariffComparator, wifiRangeSimulator, acTonnageCalculator, wallPaintingCalculator, vampireDrawSimulator, deskErgonomics, applianceCostCalculator, tileLayoutCalculator, lightingCalculator, humidityCalculator];
52
+ import { waterSoftener } from './tool/waterSoftener/entry';
53
+ export const ALL_ENTRIES = [dewPointCalculator, heatingComparator, ledSavingCalculator, projectorCalculator, qrGenerator, solarCalculator, tariffComparator, wifiRangeSimulator, acTonnageCalculator, wallPaintingCalculator, vampireDrawSimulator, deskErgonomics, applianceCostCalculator, tileLayoutCalculator, lightingCalculator, humidityCalculator, waterSoftener];
package/src/index.ts CHANGED
@@ -30,4 +30,5 @@ export { DESK_ERGONOMICS_TOOL } from './tool/deskErgonomics';
30
30
  export { APPLIANCE_COST_CALCULATOR_TOOL } from './tool/applianceCostCalculator';
31
31
  export { TILE_LAYOUT_CALCULATOR_TOOL } from './tool/tileLayoutCalculator';
32
32
  export { HUMIDITY_CALCULATOR_TOOL } from './tool/humidityCalculator';
33
+ export { WATER_SOFTENER_TOOL } from './tool/waterSoftener';
33
34
 
@@ -78,6 +78,7 @@ const { title, currentLocale = "es", localeUrls = {}, hasSidebar = false } = Ast
78
78
  transition:
79
79
  background-color 0.3s ease,
80
80
  color 0.3s ease;
81
+ font-family: Inter, sans-serif;
81
82
  }
82
83
 
83
84
  main {
@@ -0,0 +1,118 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+
4
+ type LocaleWithDiacritics = keyof typeof DIACRITIC_RULES;
5
+
6
+ const DIACRITIC_RULES = {
7
+ de: {
8
+ language: 'German',
9
+ expectedCharacters: 'ä ö ü ß',
10
+ characters: /[äöüÄÖÜß]/g,
11
+ minPerThousandLetters: 0.1,
12
+ },
13
+ es: {
14
+ language: 'Spanish',
15
+ expectedCharacters: 'á é í ó ú ü ñ',
16
+ characters: /[áéíóúüñÁÉÍÓÚÜÑ]/g,
17
+ minPerThousandLetters: 0.1,
18
+ },
19
+ fr: {
20
+ language: 'French',
21
+ expectedCharacters: 'à â æ ç é è ê ë î ï ô œ ù û ü ÿ',
22
+ characters: /[àâæçéèêëîïôœùûüÿÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ]/g,
23
+ minPerThousandLetters: 0.1,
24
+ },
25
+ it: {
26
+ language: 'Italian',
27
+ expectedCharacters: 'à è é ì í î ò ó ù ú',
28
+ characters: /[àèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ]/g,
29
+ minPerThousandLetters: 0.1,
30
+ },
31
+ pl: {
32
+ language: 'Polish',
33
+ expectedCharacters: 'ą ć ę ł ń ó ś ź ż',
34
+ characters: /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/g,
35
+ minPerThousandLetters: 0.1,
36
+ },
37
+ pt: {
38
+ language: 'Portuguese',
39
+ expectedCharacters: 'á â ã à ç é ê í ó ô õ ú ü',
40
+ characters: /[áâãàçéêíóôõúüÁÂÃÀÇÉÊÍÓÔÕÚÜ]/g,
41
+ minPerThousandLetters: 0.1,
42
+ },
43
+ sv: {
44
+ language: 'Swedish',
45
+ expectedCharacters: 'å ä ö',
46
+ characters: /[åäöÅÄÖ]/g,
47
+ minPerThousandLetters: 0.1,
48
+ },
49
+ tr: {
50
+ language: 'Turkish',
51
+ expectedCharacters: 'ç ğ ı İ ö ş ü',
52
+ characters: /[çğıöşüÇĞİÖŞÜ]/g,
53
+ minPerThousandLetters: 0.1,
54
+ },
55
+ } as const;
56
+
57
+ const LETTERS = /\p{L}/gu;
58
+ const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
59
+
60
+ function collectStrings(value: unknown): string[] {
61
+ if (typeof value === 'string') return [value];
62
+ if (!value || typeof value !== 'object') return [];
63
+ if (Array.isArray(value)) return value.flatMap(collectStrings);
64
+ return Object.values(value).flatMap(collectStrings);
65
+ }
66
+
67
+ function normalizeText(value: unknown): string {
68
+ return collectStrings(value).join(' ').normalize('NFC');
69
+ }
70
+
71
+ function translatableContent(content: Record<string, unknown>) {
72
+ return TRANSLATABLE_KEYS.map((key) => content[key]);
73
+ }
74
+
75
+ function letterCount(text: string): number {
76
+ return text.match(LETTERS)?.length ?? 0;
77
+ }
78
+
79
+ function diacriticCount(text: string, locale: LocaleWithDiacritics): number {
80
+ return text.match(DIACRITIC_RULES[locale].characters)?.length ?? 0;
81
+ }
82
+
83
+ function diacriticsPerThousandLetters(text: string, locale: LocaleWithDiacritics): number {
84
+ const letters = letterCount(text);
85
+ if (letters === 0) return 0;
86
+ return diacriticCount(text, locale) / letters * 1000;
87
+ }
88
+
89
+ describe('Diacritics density validation', () => {
90
+ ALL_TOOLS.forEach((tool) => {
91
+ describe(`Tool: ${tool.entry.id}`, () => {
92
+ Object.keys(DIACRITIC_RULES).forEach((locale) => {
93
+ it(`${locale} keeps the expected accent and special-letter set`, async () => {
94
+ const typedLocale = locale as LocaleWithDiacritics;
95
+ const loader = tool.entry.i18n[typedLocale];
96
+ if (!loader) return;
97
+
98
+ const content = await loader();
99
+ const text = normalizeText(translatableContent(content as Record<string, unknown>));
100
+ const rule = DIACRITIC_RULES[typedLocale];
101
+ const letters = letterCount(text);
102
+ const matches = diacriticCount(text, typedLocale);
103
+ const density = diacriticsPerThousandLetters(text, typedLocale);
104
+
105
+ expect(
106
+ density,
107
+ [
108
+ `Possible spelling or encoding issue detected in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
109
+ `The text has ${matches} special characters (${density.toFixed(2)} per 1000 letters, ${letters} letters analyzed).`,
110
+ `This locale should include some of these characters: ${rule.expectedCharacters}.`,
111
+ 'If the count is 0 or near 0, accents, tildes, or special letters were probably stripped by encoding or normalization.',
112
+ ].join(' '),
113
+ ).toBeGreaterThanOrEqual(rule.minPerThousandLetters);
114
+ });
115
+ });
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,84 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+
4
+ const INVERTED_PUNCTUATION_LOCALES = {
5
+ es: {
6
+ language: 'Spanish',
7
+ questionStart: '¿',
8
+ questionEnd: '?',
9
+ exclamationStart: '¡',
10
+ exclamationEnd: '!',
11
+ },
12
+ } as const;
13
+
14
+ type InvertedPunctuationLocale = keyof typeof INVERTED_PUNCTUATION_LOCALES;
15
+
16
+ const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
17
+
18
+ function collectStrings(value: unknown): string[] {
19
+ if (typeof value === 'string') return [value];
20
+ if (!value || typeof value !== 'object') return [];
21
+ if (Array.isArray(value)) return value.flatMap(collectStrings);
22
+ return Object.values(value).flatMap(collectStrings);
23
+ }
24
+
25
+ function translatableStrings(content: Record<string, unknown>): string[] {
26
+ return TRANSLATABLE_KEYS.flatMap((key) => collectStrings(content[key]));
27
+ }
28
+
29
+ function sentenceStart(text: string, endIndex: number): string {
30
+ const beforeMark = text.slice(0, endIndex).trimEnd();
31
+ const boundary = Math.max(
32
+ beforeMark.lastIndexOf('.'),
33
+ beforeMark.lastIndexOf(':'),
34
+ beforeMark.lastIndexOf(';'),
35
+ beforeMark.lastIndexOf('\n'),
36
+ );
37
+
38
+ return beforeMark.slice(boundary + 1).trimStart();
39
+ }
40
+
41
+ function findMissingInvertedMarks(
42
+ text: string,
43
+ startMark: string,
44
+ endMark: string,
45
+ ): string[] {
46
+ return [...text.matchAll(new RegExp(`\\${endMark}`, 'g'))]
47
+ .map((match) => sentenceStart(text, match.index ?? 0))
48
+ .filter((segment) => segment.length > 0 && !segment.includes(startMark))
49
+ .map((segment) => `${segment}${endMark}`);
50
+ }
51
+
52
+ describe('Inverted punctuation validation', () => {
53
+ ALL_TOOLS.forEach((tool) => {
54
+ describe(`Tool: ${tool.entry.id}`, () => {
55
+ Object.keys(INVERTED_PUNCTUATION_LOCALES).forEach((locale) => {
56
+ it(`${locale} uses opening punctuation marks for questions and exclamations`, async () => {
57
+ const typedLocale = locale as InvertedPunctuationLocale;
58
+ const loader = tool.entry.i18n[typedLocale];
59
+ if (!loader) return;
60
+
61
+ const rule = INVERTED_PUNCTUATION_LOCALES[typedLocale];
62
+ const content = await loader();
63
+ const strings = translatableStrings(content as Record<string, unknown>);
64
+ const missingQuestions = strings.flatMap((text) =>
65
+ findMissingInvertedMarks(text, rule.questionStart, rule.questionEnd)
66
+ );
67
+ const missingExclamations = strings.flatMap((text) =>
68
+ findMissingInvertedMarks(text, rule.exclamationStart, rule.exclamationEnd)
69
+ );
70
+ const failures = [...missingQuestions, ...missingExclamations];
71
+
72
+ expect(
73
+ failures,
74
+ [
75
+ `Missing opening punctuation marks in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
76
+ `Questions must use ${rule.questionStart}...${rule.questionEnd} and exclamations must use ${rule.exclamationStart}...${rule.exclamationEnd}.`,
77
+ `Examples: ${failures.slice(0, 5).join(' | ')}`,
78
+ ].join(' '),
79
+ ).toHaveLength(0);
80
+ });
81
+ });
82
+ });
83
+ });
84
+ });
@@ -17,8 +17,8 @@ describe('Locale Completeness Validation', () => {
17
17
  });
18
18
  });
19
19
 
20
- it('should have 16 tools registered', () => {
21
- expect(ALL_TOOLS.length).toBe(16);
20
+ it('should have 17 tools registered', () => {
21
+ expect(ALL_TOOLS.length).toBe(17);
22
22
  });
23
23
  });
24
24
 
@@ -0,0 +1,94 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+
4
+ type ScriptLocale = keyof typeof SCRIPT_RULES;
5
+
6
+ const SCRIPT_RULES = {
7
+ ja: {
8
+ language: 'Japanese',
9
+ scriptName: 'kana/kanji',
10
+ scriptCharacters: /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/gu,
11
+ minScriptRatio: 0.45,
12
+ },
13
+ ko: {
14
+ language: 'Korean',
15
+ scriptName: 'hangul',
16
+ scriptCharacters: /\p{Script=Hangul}/gu,
17
+ minScriptRatio: 0.55,
18
+ },
19
+ ru: {
20
+ language: 'Russian',
21
+ scriptName: 'cyrillic',
22
+ scriptCharacters: /\p{Script=Cyrillic}/gu,
23
+ minScriptRatio: 0.65,
24
+ },
25
+ zh: {
26
+ language: 'Chinese',
27
+ scriptName: 'han',
28
+ scriptCharacters: /\p{Script=Han}/gu,
29
+ minScriptRatio: 0.45,
30
+ },
31
+ } as const;
32
+
33
+ const LETTERS = /\p{L}/gu;
34
+ const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
35
+
36
+ function collectStrings(value: unknown): string[] {
37
+ if (typeof value === 'string') return [value];
38
+ if (!value || typeof value !== 'object') return [];
39
+ if (Array.isArray(value)) return value.flatMap(collectStrings);
40
+ return Object.values(value).flatMap(collectStrings);
41
+ }
42
+
43
+ function normalizeText(value: unknown): string {
44
+ return collectStrings(value).join(' ').normalize('NFC');
45
+ }
46
+
47
+ function translatableContent(content: Record<string, unknown>) {
48
+ return TRANSLATABLE_KEYS.map((key) => content[key]);
49
+ }
50
+
51
+ function letterCount(text: string): number {
52
+ return text.match(LETTERS)?.length ?? 0;
53
+ }
54
+
55
+ function scriptCount(text: string, locale: ScriptLocale): number {
56
+ return text.match(SCRIPT_RULES[locale].scriptCharacters)?.length ?? 0;
57
+ }
58
+
59
+ function scriptRatio(text: string, locale: ScriptLocale): number {
60
+ const letters = letterCount(text);
61
+ if (letters === 0) return 0;
62
+ return scriptCount(text, locale) / letters;
63
+ }
64
+
65
+ describe('Native script density validation', () => {
66
+ ALL_TOOLS.forEach((tool) => {
67
+ describe(`Tool: ${tool.entry.id}`, () => {
68
+ Object.keys(SCRIPT_RULES).forEach((locale) => {
69
+ it(`${locale} keeps most translated text in its native script`, async () => {
70
+ const typedLocale = locale as ScriptLocale;
71
+ const loader = tool.entry.i18n[typedLocale];
72
+ if (!loader) return;
73
+
74
+ const content = await loader();
75
+ const rule = SCRIPT_RULES[typedLocale];
76
+ const text = normalizeText(translatableContent(content as Record<string, unknown>));
77
+ const letters = letterCount(text);
78
+ const matches = scriptCount(text, typedLocale);
79
+ const ratio = scriptRatio(text, typedLocale);
80
+
81
+ expect(
82
+ ratio,
83
+ [
84
+ `Possible broken translation detected in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
85
+ `The text has ${matches} ${rule.scriptName} characters out of ${letters} analyzed letters (${(ratio * 100).toFixed(1)}%).`,
86
+ `Most translatable content should be written in ${rule.scriptName} script.`,
87
+ 'Non-translatable fields such as slug, bibliography, and schemas are ignored to avoid false positives.',
88
+ ].join(' '),
89
+ ).toBeGreaterThanOrEqual(rule.minScriptRatio);
90
+ });
91
+ });
92
+ });
93
+ });
94
+ });
@@ -4,8 +4,8 @@ import { homeCategory } from '../data';
4
4
 
5
5
  describe('Tool Validation Suite', () => {
6
6
  describe('Library Registration', () => {
7
- it('should have 16 tools in ALL_TOOLS', () => {
8
- expect(ALL_TOOLS.length).toBe(16);
7
+ it('should have 17 tools in ALL_TOOLS', () => {
8
+ expect(ALL_TOOLS.length).toBe(17);
9
9
  });
10
10
 
11
11
  it('homeCategory should be defined', () => {