@jjlmoya/utils-science 1.42.0 → 1.44.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 (152) hide show
  1. package/package.json +1 -1
  2. package/src/category/index.ts +4 -1
  3. package/src/entries.ts +7 -1
  4. package/src/index.ts +3 -0
  5. package/src/tests/diacritics_density.test.ts +140 -0
  6. package/src/tests/inverted_punctuation.test.ts +84 -0
  7. package/src/tests/locale_completeness.test.ts +2 -2
  8. package/src/tests/script_density.test.ts +94 -0
  9. package/src/tests/tool_validation.test.ts +2 -3
  10. package/src/tool/black-hole-event-horizon-simulator/bibliography.astro +14 -0
  11. package/src/tool/black-hole-event-horizon-simulator/bibliography.ts +16 -0
  12. package/src/tool/black-hole-event-horizon-simulator/black-hole-event-horizon-simulator.css +366 -0
  13. package/src/tool/black-hole-event-horizon-simulator/component.astro +302 -0
  14. package/src/tool/black-hole-event-horizon-simulator/entry.ts +29 -0
  15. package/src/tool/black-hole-event-horizon-simulator/i18n/de.ts +179 -0
  16. package/src/tool/black-hole-event-horizon-simulator/i18n/en.ts +259 -0
  17. package/src/tool/black-hole-event-horizon-simulator/i18n/es.ts +259 -0
  18. package/src/tool/black-hole-event-horizon-simulator/i18n/fr.ts +179 -0
  19. package/src/tool/black-hole-event-horizon-simulator/i18n/id.ts +259 -0
  20. package/src/tool/black-hole-event-horizon-simulator/i18n/it.ts +179 -0
  21. package/src/tool/black-hole-event-horizon-simulator/i18n/ja.ts +179 -0
  22. package/src/tool/black-hole-event-horizon-simulator/i18n/ko.ts +259 -0
  23. package/src/tool/black-hole-event-horizon-simulator/i18n/nl.ts +179 -0
  24. package/src/tool/black-hole-event-horizon-simulator/i18n/pl.ts +259 -0
  25. package/src/tool/black-hole-event-horizon-simulator/i18n/pt.ts +179 -0
  26. package/src/tool/black-hole-event-horizon-simulator/i18n/ru.ts +259 -0
  27. package/src/tool/black-hole-event-horizon-simulator/i18n/sv.ts +179 -0
  28. package/src/tool/black-hole-event-horizon-simulator/i18n/tr.ts +179 -0
  29. package/src/tool/black-hole-event-horizon-simulator/i18n/zh.ts +179 -0
  30. package/src/tool/black-hole-event-horizon-simulator/index.ts +11 -0
  31. package/src/tool/black-hole-event-horizon-simulator/logic.ts +68 -0
  32. package/src/tool/black-hole-event-horizon-simulator/seo.astro +15 -0
  33. package/src/tool/conway-life-rule-lab/i18n/de.ts +62 -5
  34. package/src/tool/conway-life-rule-lab/i18n/es.ts +62 -5
  35. package/src/tool/conway-life-rule-lab/i18n/fr.ts +62 -5
  36. package/src/tool/conway-life-rule-lab/i18n/id.ts +102 -45
  37. package/src/tool/conway-life-rule-lab/i18n/it.ts +62 -5
  38. package/src/tool/conway-life-rule-lab/i18n/ja.ts +62 -5
  39. package/src/tool/conway-life-rule-lab/i18n/ko.ts +62 -5
  40. package/src/tool/conway-life-rule-lab/i18n/nl.ts +102 -45
  41. package/src/tool/conway-life-rule-lab/i18n/pl.ts +62 -5
  42. package/src/tool/conway-life-rule-lab/i18n/pt.ts +62 -5
  43. package/src/tool/conway-life-rule-lab/i18n/ru.ts +62 -5
  44. package/src/tool/conway-life-rule-lab/i18n/sv.ts +62 -5
  45. package/src/tool/conway-life-rule-lab/i18n/tr.ts +62 -5
  46. package/src/tool/conway-life-rule-lab/i18n/zh.ts +62 -5
  47. package/src/tool/cosmic-inflation/i18n/es.ts +5 -5
  48. package/src/tool/cosmic-inflation/i18n/it.ts +51 -51
  49. package/src/tool/cosmic-inflation/i18n/ru.ts +42 -150
  50. package/src/tool/double-slit-decoherence/i18n/fr.ts +42 -86
  51. package/src/tool/double-slit-decoherence/i18n/it.ts +28 -72
  52. package/src/tool/double-slit-decoherence/i18n/pt.ts +35 -79
  53. package/src/tool/double-slit-decoherence/i18n/ru.ts +59 -59
  54. package/src/tool/double-slit-decoherence/i18n/sv.ts +33 -81
  55. package/src/tool/double-slit-decoherence/i18n/tr.ts +55 -55
  56. package/src/tool/dyson-sphere-energy-capture/i18n/de.ts +42 -123
  57. package/src/tool/dyson-sphere-energy-capture/i18n/es.ts +6 -6
  58. package/src/tool/dyson-sphere-energy-capture/i18n/fr.ts +63 -131
  59. package/src/tool/dyson-sphere-energy-capture/i18n/it.ts +36 -113
  60. package/src/tool/dyson-sphere-energy-capture/i18n/ja.ts +66 -42
  61. package/src/tool/dyson-sphere-energy-capture/i18n/ko.ts +66 -42
  62. package/src/tool/dyson-sphere-energy-capture/i18n/pl.ts +50 -133
  63. package/src/tool/dyson-sphere-energy-capture/i18n/pt.ts +51 -132
  64. package/src/tool/dyson-sphere-energy-capture/i18n/ru.ts +61 -98
  65. package/src/tool/dyson-sphere-energy-capture/i18n/sv.ts +56 -137
  66. package/src/tool/dyson-sphere-energy-capture/i18n/tr.ts +61 -142
  67. package/src/tool/dyson-sphere-energy-capture/i18n/zh.ts +67 -43
  68. package/src/tool/epidemic-sir-simulator/bibliography.astro +15 -0
  69. package/src/tool/epidemic-sir-simulator/bibliography.ts +37 -0
  70. package/src/tool/epidemic-sir-simulator/component.astro +384 -0
  71. package/src/tool/epidemic-sir-simulator/entry.ts +30 -0
  72. package/src/tool/epidemic-sir-simulator/epidemic-sir-simulator.css +624 -0
  73. package/src/tool/epidemic-sir-simulator/i18n/de.ts +347 -0
  74. package/src/tool/epidemic-sir-simulator/i18n/en.ts +347 -0
  75. package/src/tool/epidemic-sir-simulator/i18n/es.ts +347 -0
  76. package/src/tool/epidemic-sir-simulator/i18n/fr.ts +347 -0
  77. package/src/tool/epidemic-sir-simulator/i18n/id.ts +347 -0
  78. package/src/tool/epidemic-sir-simulator/i18n/it.ts +347 -0
  79. package/src/tool/epidemic-sir-simulator/i18n/ja.ts +347 -0
  80. package/src/tool/epidemic-sir-simulator/i18n/ko.ts +347 -0
  81. package/src/tool/epidemic-sir-simulator/i18n/nl.ts +347 -0
  82. package/src/tool/epidemic-sir-simulator/i18n/pl.ts +347 -0
  83. package/src/tool/epidemic-sir-simulator/i18n/pt.ts +347 -0
  84. package/src/tool/epidemic-sir-simulator/i18n/ru.ts +347 -0
  85. package/src/tool/epidemic-sir-simulator/i18n/sv.ts +347 -0
  86. package/src/tool/epidemic-sir-simulator/i18n/tr.ts +347 -0
  87. package/src/tool/epidemic-sir-simulator/i18n/zh.ts +347 -0
  88. package/src/tool/epidemic-sir-simulator/index.ts +12 -0
  89. package/src/tool/epidemic-sir-simulator/logic.ts +163 -0
  90. package/src/tool/epidemic-sir-simulator/seo.astro +16 -0
  91. package/src/tool/fermi-paradox-filter-lab/bibliography.astro +14 -0
  92. package/src/tool/fermi-paradox-filter-lab/bibliography.ts +24 -0
  93. package/src/tool/fermi-paradox-filter-lab/component.astro +257 -0
  94. package/src/tool/fermi-paradox-filter-lab/entry.ts +26 -0
  95. package/src/tool/fermi-paradox-filter-lab/fermi-paradox-filter-lab.css +228 -0
  96. package/src/tool/fermi-paradox-filter-lab/i18n/de.ts +192 -0
  97. package/src/tool/fermi-paradox-filter-lab/i18n/en.ts +192 -0
  98. package/src/tool/fermi-paradox-filter-lab/i18n/es.ts +193 -0
  99. package/src/tool/fermi-paradox-filter-lab/i18n/fr.ts +192 -0
  100. package/src/tool/fermi-paradox-filter-lab/i18n/id.ts +192 -0
  101. package/src/tool/fermi-paradox-filter-lab/i18n/it.ts +192 -0
  102. package/src/tool/fermi-paradox-filter-lab/i18n/ja.ts +192 -0
  103. package/src/tool/fermi-paradox-filter-lab/i18n/ko.ts +192 -0
  104. package/src/tool/fermi-paradox-filter-lab/i18n/nl.ts +192 -0
  105. package/src/tool/fermi-paradox-filter-lab/i18n/pl.ts +193 -0
  106. package/src/tool/fermi-paradox-filter-lab/i18n/pt.ts +192 -0
  107. package/src/tool/fermi-paradox-filter-lab/i18n/ru.ts +192 -0
  108. package/src/tool/fermi-paradox-filter-lab/i18n/sv.ts +192 -0
  109. package/src/tool/fermi-paradox-filter-lab/i18n/tr.ts +192 -0
  110. package/src/tool/fermi-paradox-filter-lab/i18n/zh.ts +192 -0
  111. package/src/tool/fermi-paradox-filter-lab/index.ts +11 -0
  112. package/src/tool/fermi-paradox-filter-lab/logic.ts +125 -0
  113. package/src/tool/fermi-paradox-filter-lab/seo.astro +15 -0
  114. package/src/tool/global-albedo-snowball-simulator/i18n/ru.ts +50 -63
  115. package/src/tool/lorenz-attractor/i18n/de.ts +52 -78
  116. package/src/tool/lorenz-attractor/i18n/es.ts +5 -5
  117. package/src/tool/lorenz-attractor/i18n/fr.ts +51 -77
  118. package/src/tool/lorenz-attractor/i18n/it.ts +36 -36
  119. package/src/tool/lorenz-attractor/i18n/pt.ts +51 -75
  120. package/src/tool/mandelbrot-fractal/i18n/de.ts +31 -58
  121. package/src/tool/mandelbrot-fractal/i18n/es.ts +5 -5
  122. package/src/tool/mandelbrot-fractal/i18n/fr.ts +39 -57
  123. package/src/tool/mandelbrot-fractal/i18n/it.ts +30 -48
  124. package/src/tool/mandelbrot-fractal/i18n/pl.ts +34 -52
  125. package/src/tool/mandelbrot-fractal/i18n/pt.ts +30 -30
  126. package/src/tool/mandelbrot-fractal/i18n/ru.ts +42 -60
  127. package/src/tool/mandelbrot-fractal/i18n/sv.ts +38 -65
  128. package/src/tool/natural-selection-drift/i18n/it.ts +18 -95
  129. package/src/tool/natural-selection-drift/i18n/pt.ts +76 -19
  130. package/src/tool/natural-selection-drift/i18n/ru.ts +27 -24
  131. package/src/tool/natural-selection-drift/i18n/sv.ts +9 -6
  132. package/src/tool/phase-diagram-critical-points/i18n/de.ts +30 -68
  133. package/src/tool/phase-diagram-critical-points/i18n/es.ts +4 -4
  134. package/src/tool/phase-diagram-critical-points/i18n/fr.ts +37 -75
  135. package/src/tool/phase-diagram-critical-points/i18n/it.ts +8 -8
  136. package/src/tool/planet-atmosphere-survival/i18n/ru.ts +49 -192
  137. package/src/tool/radioactive-decay/i18n/de.ts +16 -32
  138. package/src/tool/radioactive-decay/i18n/es.ts +5 -5
  139. package/src/tool/radioactive-decay/i18n/fr.ts +24 -40
  140. package/src/tool/radioactive-decay/i18n/it.ts +18 -35
  141. package/src/tool/radioactive-decay/i18n/pt.ts +34 -34
  142. package/src/tool/roche-limit-satellite-disruption/i18n/pl.ts +52 -128
  143. package/src/tool/temperature-timeline/i18n/de.ts +46 -174
  144. package/src/tool/temperature-timeline/i18n/es.ts +5 -5
  145. package/src/tool/temperature-timeline/i18n/fr.ts +69 -144
  146. package/src/tool/temperature-timeline/i18n/it.ts +34 -133
  147. package/src/tool/temperature-timeline/i18n/pt.ts +35 -174
  148. package/src/tool/temperature-timeline/i18n/ru.ts +48 -174
  149. package/src/tool/twin-paradox-visualizer/i18n/es.ts +5 -5
  150. package/src/tool/twin-paradox-visualizer/i18n/fr.ts +34 -34
  151. package/src/tool/twin-paradox-visualizer/i18n/pt.ts +31 -71
  152. package/src/tools.ts +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjlmoya/utils-science",
3
- "version": "1.42.0",
3
+ "version": "1.44.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -22,10 +22,13 @@ import { dysonSphereEnergyCapture } from '../tool/dyson-sphere-energy-capture/in
22
22
  import { globalAlbedoSnowballSimulator } from '../tool/global-albedo-snowball-simulator/index';
23
23
  import { conwayLifeRuleLab } from '../tool/conway-life-rule-lab/index';
24
24
  import { crystalLatticeStructureFinder } from '../tool/crystal-lattice-structure-finder/index';
25
+ import { fermiParadoxFilterLab } from '../tool/fermi-paradox-filter-lab/index';
26
+ import { epidemicSirSimulator } from '../tool/epidemic-sir-simulator/index';
27
+ import { blackHoleEventHorizonSimulator } from '../tool/black-hole-event-horizon-simulator/index';
25
28
 
26
29
  export const scienceCategory: ScienceCategoryEntry = {
27
30
  icon: 'mdi:flask',
28
- tools: [colonyCounter, asteroidImpact, microwaveDetector, simulationProbability, cellularRenewal, cosmicInflation, temperatureTimeline, lorenzAttractor, stellarHabitabilityZone, radioactiveDecay, naturalSelectionDrift, entropySecondLaw, doubleSlitDecoherence, phaseDiagramCriticalPoints, twinParadoxVisualizer, mandelbrotFractal, planetAtmosphereSurvival, threeBodyProblem, rocheLimitSatelliteDisruption, dysonSphereEnergyCapture, globalAlbedoSnowballSimulator, conwayLifeRuleLab, crystalLatticeStructureFinder],
31
+ tools: [colonyCounter, asteroidImpact, microwaveDetector, simulationProbability, cellularRenewal, cosmicInflation, temperatureTimeline, lorenzAttractor, stellarHabitabilityZone, radioactiveDecay, naturalSelectionDrift, entropySecondLaw, doubleSlitDecoherence, phaseDiagramCriticalPoints, twinParadoxVisualizer, mandelbrotFractal, planetAtmosphereSurvival, threeBodyProblem, rocheLimitSatelliteDisruption, dysonSphereEnergyCapture, globalAlbedoSnowballSimulator, conwayLifeRuleLab, crystalLatticeStructureFinder, fermiParadoxFilterLab, epidemicSirSimulator, blackHoleEventHorizonSimulator],
29
32
  i18n: {
30
33
  es: () => import('./i18n/es').then((m) => m.content),
31
34
  en: () => import('./i18n/en').then((m) => m.content),
package/src/entries.ts CHANGED
@@ -22,6 +22,9 @@ export { dysonSphereEnergyCapture } from './tool/dyson-sphere-energy-capture/ent
22
22
  export { globalAlbedoSnowballSimulator } from './tool/global-albedo-snowball-simulator/entry';
23
23
  export { conwayLifeRuleLab } from './tool/conway-life-rule-lab/entry';
24
24
  export { crystalLatticeStructureFinder } from './tool/crystal-lattice-structure-finder/entry';
25
+ export { fermiParadoxFilterLab } from './tool/fermi-paradox-filter-lab/entry';
26
+ export { epidemicSirSimulator } from './tool/epidemic-sir-simulator/entry';
27
+ export { blackHoleEventHorizonSimulator } from './tool/black-hole-event-horizon-simulator/entry';
25
28
  export { scienceCategory } from './category';
26
29
  import { asteroidImpact } from './tool/asteroid-impact/entry';
27
30
  import { cellularRenewal } from './tool/cellular-renewal/entry';
@@ -46,4 +49,7 @@ import { dysonSphereEnergyCapture } from './tool/dyson-sphere-energy-capture/ent
46
49
  import { globalAlbedoSnowballSimulator } from './tool/global-albedo-snowball-simulator/entry';
47
50
  import { conwayLifeRuleLab } from './tool/conway-life-rule-lab/entry';
48
51
  import { crystalLatticeStructureFinder } from './tool/crystal-lattice-structure-finder/entry';
49
- export const ALL_ENTRIES = [asteroidImpact, cellularRenewal, colonyCounter, microwaveDetector, simulationProbability, cosmicInflation, temperatureTimeline, lorenzAttractor, stellarHabitabilityZone, radioactiveDecay, naturalSelectionDrift, entropySecondLaw, doubleSlitDecoherence, phaseDiagramCriticalPoints, twinParadoxVisualizer, mandelbrotFractal, planetAtmosphereSurvival, threeBodyProblem, rocheLimitSatelliteDisruption, dysonSphereEnergyCapture, globalAlbedoSnowballSimulator, conwayLifeRuleLab, crystalLatticeStructureFinder];
52
+ import { fermiParadoxFilterLab } from './tool/fermi-paradox-filter-lab/entry';
53
+ import { epidemicSirSimulator } from './tool/epidemic-sir-simulator/entry';
54
+ import { blackHoleEventHorizonSimulator } from './tool/black-hole-event-horizon-simulator/entry';
55
+ export const ALL_ENTRIES = [asteroidImpact, cellularRenewal, colonyCounter, microwaveDetector, simulationProbability, cosmicInflation, temperatureTimeline, lorenzAttractor, stellarHabitabilityZone, radioactiveDecay, naturalSelectionDrift, entropySecondLaw, doubleSlitDecoherence, phaseDiagramCriticalPoints, twinParadoxVisualizer, mandelbrotFractal, planetAtmosphereSurvival, threeBodyProblem, rocheLimitSatelliteDisruption, dysonSphereEnergyCapture, globalAlbedoSnowballSimulator, conwayLifeRuleLab, crystalLatticeStructureFinder, fermiParadoxFilterLab, epidemicSirSimulator, blackHoleEventHorizonSimulator];
package/src/index.ts CHANGED
@@ -23,6 +23,9 @@ export { DYSON_SPHERE_ENERGY_CAPTURE_TOOL } from './tool/dyson-sphere-energy-cap
23
23
  export { GLOBAL_ALBEDO_SNOWBALL_SIMULATOR_TOOL } from './tool/global-albedo-snowball-simulator/index';
24
24
  export { CONWAY_LIFE_RULE_LAB_TOOL } from './tool/conway-life-rule-lab/index';
25
25
  export { CRYSTAL_LATTICE_STRUCTURE_FINDER_TOOL } from './tool/crystal-lattice-structure-finder/index';
26
+ export { FERMI_PARADOX_FILTER_LAB_TOOL } from './tool/fermi-paradox-filter-lab/index';
27
+ export { EPIDEMIC_SIR_SIMULATOR_TOOL } from './tool/epidemic-sir-simulator/index';
28
+ export { BLACK_HOLE_EVENT_HORIZON_SIMULATOR_TOOL } from './tool/black-hole-event-horizon-simulator/index';
26
29
 
27
30
  export type {
28
31
  KnownLocale,
@@ -0,0 +1,140 @@
1
+ import { describe, expect, it, afterAll } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+
4
+ const failures: Map<string, string[]> = new Map();
5
+
6
+ type LocaleWithDiacritics = keyof typeof DIACRITIC_RULES;
7
+
8
+ const DIACRITIC_RULES = {
9
+ de: {
10
+ language: 'German',
11
+ expectedCharacters: 'ä ö ü ß',
12
+ characters: /[äöüÄÖÜß]/g,
13
+ minPerThousandLetters: 0.1,
14
+ },
15
+ es: {
16
+ language: 'Spanish',
17
+ expectedCharacters: 'á é í ó ú ü ñ',
18
+ characters: /[áéíóúüñÁÉÍÓÚÜÑ]/g,
19
+ minPerThousandLetters: 0.1,
20
+ },
21
+ fr: {
22
+ language: 'French',
23
+ expectedCharacters: 'à â æ ç é è ê ë î ï ô œ ù û ü ÿ',
24
+ characters: /[àâæçéèêëîïôœùûüÿÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ]/g,
25
+ minPerThousandLetters: 0.1,
26
+ },
27
+ it: {
28
+ language: 'Italian',
29
+ expectedCharacters: 'à è é ì í î ò ó ù ú',
30
+ characters: /[àèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ]/g,
31
+ minPerThousandLetters: 0.1,
32
+ },
33
+ pl: {
34
+ language: 'Polish',
35
+ expectedCharacters: 'ą ć ę ł ń ó ś ź ż',
36
+ characters: /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/g,
37
+ minPerThousandLetters: 0.1,
38
+ },
39
+ pt: {
40
+ language: 'Portuguese',
41
+ expectedCharacters: 'á â ã à ç é ê í ó ô õ ú ü',
42
+ characters: /[áâãàçéêíóôõúüÁÂÃÀÇÉÊÍÓÔÕÚÜ]/g,
43
+ minPerThousandLetters: 0.1,
44
+ },
45
+ sv: {
46
+ language: 'Swedish',
47
+ expectedCharacters: 'å ä ö',
48
+ characters: /[åäöÅÄÖ]/g,
49
+ minPerThousandLetters: 0.1,
50
+ },
51
+ tr: {
52
+ language: 'Turkish',
53
+ expectedCharacters: 'ç ğ ı İ ö ş ü',
54
+ characters: /[çğıöşüÇĞİÖŞÜ]/g,
55
+ minPerThousandLetters: 0.1,
56
+ },
57
+ } as const;
58
+
59
+ const LETTERS = /\p{L}/gu;
60
+ const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
61
+
62
+ function collectStrings(value: unknown): string[] {
63
+ if (typeof value === 'string') return [value];
64
+ if (!value || typeof value !== 'object') return [];
65
+ if (Array.isArray(value)) return value.flatMap(collectStrings);
66
+ return Object.values(value).flatMap(collectStrings);
67
+ }
68
+
69
+ function normalizeText(value: unknown): string {
70
+ return collectStrings(value).join(' ').normalize('NFC');
71
+ }
72
+
73
+ function translatableContent(content: Record<string, unknown>) {
74
+ return TRANSLATABLE_KEYS.map((key) => content[key]);
75
+ }
76
+
77
+ function letterCount(text: string): number {
78
+ return text.match(LETTERS)?.length ?? 0;
79
+ }
80
+
81
+ function diacriticCount(text: string, locale: LocaleWithDiacritics): number {
82
+ return text.match(DIACRITIC_RULES[locale].characters)?.length ?? 0;
83
+ }
84
+
85
+ function diacriticsPerThousandLetters(text: string, locale: LocaleWithDiacritics): number {
86
+ const letters = letterCount(text);
87
+ if (letters === 0) return 0;
88
+ return diacriticCount(text, locale) / letters * 1000;
89
+ }
90
+
91
+ describe('Diacritics density validation', () => {
92
+ ALL_TOOLS.forEach((tool) => {
93
+ describe(`Tool: ${tool.entry.id}`, () => {
94
+ Object.keys(DIACRITIC_RULES).forEach((locale) => {
95
+ it(`${locale} keeps the expected accent and special-letter set`, async () => {
96
+ const typedLocale = locale as LocaleWithDiacritics;
97
+ const loader = tool.entry.i18n[typedLocale];
98
+ if (!loader) return;
99
+
100
+ const content = await loader();
101
+ const text = normalizeText(translatableContent(content as Record<string, unknown>));
102
+ const rule = DIACRITIC_RULES[typedLocale];
103
+ const letters = letterCount(text);
104
+ const matches = diacriticCount(text, typedLocale);
105
+ const density = diacriticsPerThousandLetters(text, typedLocale);
106
+
107
+ expect(
108
+ density,
109
+ [
110
+ `Possible spelling or encoding issue detected in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
111
+ `The text has ${matches} special characters (${density.toFixed(2)} per 1000 letters, ${letters} letters analyzed).`,
112
+ `This locale should include some of these characters: ${rule.expectedCharacters}.`,
113
+ 'If the count is 0 or near 0, accents, tildes, or special letters were probably stripped by encoding or normalization.',
114
+ ].join(' '),
115
+ ).toBeGreaterThanOrEqual(rule.minPerThousandLetters);
116
+
117
+ if (density < rule.minPerThousandLetters) {
118
+ const existing = failures.get(tool.entry.id) ?? [];
119
+ existing.push(typedLocale);
120
+ failures.set(tool.entry.id, existing);
121
+ }
122
+ });
123
+ });
124
+ });
125
+ });
126
+ });
127
+
128
+ afterAll(() => {
129
+ if (failures.size > 0) {
130
+ const sorted = [...failures.entries()].sort(([a], [b]) => a.localeCompare(b));
131
+ console.log('\n=== DIACRITICS DENSITY FAILURES (grouped by tool) ===');
132
+ let total = 0;
133
+ for (const [tool, locales] of sorted) {
134
+ locales.sort();
135
+ console.log(` ${tool}: ${locales.join(', ')}`);
136
+ total += locales.length;
137
+ }
138
+ console.log(` Total: ${total} failures across ${failures.size} tools\n`);
139
+ }
140
+ });
@@ -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
+ });
@@ -18,7 +18,7 @@ describe('Locale Completeness Validation', () => {
18
18
  });
19
19
  });
20
20
 
21
- it('all 23 tools registered', () => {
22
- expect(ALL_TOOLS.length).toBe(23);
21
+ it('all 26 tools registered', () => {
22
+ expect(ALL_TOOLS.length).toBe(26);
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 { scienceCategory } from '../data';
4
4
 
5
5
  describe('Tool Validation Suite', () => {
6
6
  describe('Library Registration', () => {
7
- it('should have 23 tools in ALL_TOOLS', () => {
8
- expect(ALL_TOOLS.length).toBe(23);
7
+ it('should have 26 tools in ALL_TOOLS', () => {
8
+ expect(ALL_TOOLS.length).toBe(26);
9
9
  });
10
10
 
11
11
  it('scienceCategory should be defined', () => {
@@ -14,4 +14,3 @@ describe('Tool Validation Suite', () => {
14
14
  });
15
15
  });
16
16
  });
17
-
@@ -0,0 +1,14 @@
1
+ ---
2
+ import { Bibliography as SharedBibliography } from '@jjlmoya/utils-shared';
3
+ import { blackHoleEventHorizonSimulator } from './index';
4
+ import type { KnownLocale } from '../../types';
5
+
6
+ interface Props {
7
+ locale?: KnownLocale;
8
+ }
9
+
10
+ const { locale = 'en' } = Astro.props;
11
+ const content = await blackHoleEventHorizonSimulator.i18n[locale]?.();
12
+ ---
13
+
14
+ {content && <SharedBibliography links={content.bibliography} />}
@@ -0,0 +1,16 @@
1
+ import type { BibliographyEntry } from '../../types';
2
+
3
+ export const bibliography: BibliographyEntry[] = [
4
+ {
5
+ name: 'Event Horizon Telescope Collaboration, First M87 Event Horizon Telescope Results',
6
+ url: 'https://ui.adsabs.harvard.edu/abs/2019ApJ...875L...1E',
7
+ },
8
+ {
9
+ name: 'NASA, Black Holes',
10
+ url: 'https://science.nasa.gov/universe/black-holes/',
11
+ },
12
+ {
13
+ name: 'The Foundation of the General Theory of Relativity',
14
+ url: 'https://ia801808.us.archive.org/3/items/the-foundation-of-the-general-theory-of-relativity/The%20Foundation%20of%20the%20General%20Theory%20of%20Relativity.pdf',
15
+ }
16
+ ];