@datamoc/mw_games 0.4.1 → 0.4.3

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 (260) hide show
  1. package/README.md +2 -2
  2. package/dist/actors/ItemStatusEffect.d.ts +1 -1
  3. package/dist/actors/ItemStatusEffect.d.ts.map +1 -1
  4. package/dist/actors/ItemStatusEffect.js +2 -11
  5. package/dist/actors/ItemStatusEffect.js.map +1 -1
  6. package/dist/actors/StatusEffect.d.ts +11 -0
  7. package/dist/actors/StatusEffect.d.ts.map +1 -1
  8. package/dist/actors/StatusEffect.js +21 -8
  9. package/dist/actors/StatusEffect.js.map +1 -1
  10. package/dist/assets/binary.d.ts +52 -0
  11. package/dist/assets/binary.d.ts.map +1 -0
  12. package/dist/assets/binary.js +57 -0
  13. package/dist/assets/binary.js.map +1 -0
  14. package/dist/assets/index.d.ts +10 -5
  15. package/dist/assets/index.d.ts.map +1 -1
  16. package/dist/assets/index.js +9 -5
  17. package/dist/assets/index.js.map +1 -1
  18. package/dist/board/Army.d.ts +75 -0
  19. package/dist/board/Army.d.ts.map +1 -1
  20. package/dist/board/Army.js +75 -0
  21. package/dist/board/Army.js.map +1 -1
  22. package/dist/board/Classics.d.ts +297 -1
  23. package/dist/board/Classics.d.ts.map +1 -1
  24. package/dist/board/Classics.js +297 -1
  25. package/dist/board/Classics.js.map +1 -1
  26. package/dist/board/Engine.d.ts +23 -0
  27. package/dist/board/Engine.d.ts.map +1 -1
  28. package/dist/board/Engine.js +23 -0
  29. package/dist/board/Engine.js.map +1 -1
  30. package/dist/board/FogOfWar.d.ts +20 -0
  31. package/dist/board/FogOfWar.d.ts.map +1 -1
  32. package/dist/board/FogOfWar.js +20 -0
  33. package/dist/board/FogOfWar.js.map +1 -1
  34. package/dist/board/Tactics.d.ts +158 -1
  35. package/dist/board/Tactics.d.ts.map +1 -1
  36. package/dist/board/Tactics.js +125 -1
  37. package/dist/board/Tactics.js.map +1 -1
  38. package/dist/board/chess.d.ts +87 -3
  39. package/dist/board/chess.d.ts.map +1 -1
  40. package/dist/board/chess.js +96 -4
  41. package/dist/board/chess.js.map +1 -1
  42. package/dist/core/HttpTransport.d.ts +1 -1
  43. package/dist/core/HttpTransport.js +1 -1
  44. package/dist/core/News.d.ts +6 -13
  45. package/dist/core/News.d.ts.map +1 -1
  46. package/dist/core/News.js +10 -23
  47. package/dist/core/News.js.map +1 -1
  48. package/dist/core/RunHistory.d.ts +1 -2
  49. package/dist/core/RunHistory.d.ts.map +1 -1
  50. package/dist/core/RunHistory.js +5 -6
  51. package/dist/core/RunHistory.js.map +1 -1
  52. package/dist/core/Stats.d.ts +1 -2
  53. package/dist/core/Stats.d.ts.map +1 -1
  54. package/dist/core/Stats.js +5 -6
  55. package/dist/core/Stats.js.map +1 -1
  56. package/dist/core/StoredValue.d.ts +21 -0
  57. package/dist/core/StoredValue.d.ts.map +1 -0
  58. package/dist/core/StoredValue.js +28 -0
  59. package/dist/core/StoredValue.js.map +1 -0
  60. package/dist/i18n/Content.d.ts +151 -0
  61. package/dist/i18n/Content.d.ts.map +1 -0
  62. package/dist/i18n/Content.js +219 -0
  63. package/dist/i18n/Content.js.map +1 -0
  64. package/dist/i18n/index.d.ts +35 -3
  65. package/dist/i18n/index.d.ts.map +1 -1
  66. package/dist/i18n/index.js +88 -6
  67. package/dist/i18n/index.js.map +1 -1
  68. package/dist/mw_games.global.js +90 -90
  69. package/dist/roguelike/Level.d.ts +10 -0
  70. package/dist/roguelike/Level.d.ts.map +1 -1
  71. package/dist/roguelike/Level.js +57 -17
  72. package/dist/roguelike/Level.js.map +1 -1
  73. package/dist/roguelike/Pathfinder.js +19 -19
  74. package/dist/roguelike/Pathfinder.js.map +1 -1
  75. package/dist/roguelike/Placement.d.ts +62 -0
  76. package/dist/roguelike/Placement.d.ts.map +1 -0
  77. package/dist/roguelike/Placement.js +79 -0
  78. package/dist/roguelike/Placement.js.map +1 -0
  79. package/dist/roguelike/index.d.ts +2 -0
  80. package/dist/roguelike/index.d.ts.map +1 -1
  81. package/dist/roguelike/index.js +1 -0
  82. package/dist/roguelike/index.js.map +1 -1
  83. package/dist/rpg/FreeMover.d.ts +1 -1
  84. package/dist/rpg/FreeMover.d.ts.map +1 -1
  85. package/dist/rpg/FreeMover.js +3 -6
  86. package/dist/rpg/FreeMover.js.map +1 -1
  87. package/dist/rpg/GridMover.d.ts +1 -1
  88. package/dist/rpg/GridMover.d.ts.map +1 -1
  89. package/dist/rpg/GridMover.js +3 -6
  90. package/dist/rpg/GridMover.js.map +1 -1
  91. package/dist/rpg/MovableSprite.d.ts +6 -0
  92. package/dist/rpg/MovableSprite.d.ts.map +1 -1
  93. package/dist/rpg/MovableSprite.js +9 -1
  94. package/dist/rpg/MovableSprite.js.map +1 -1
  95. package/dist/three-d/Models.d.ts +38 -1
  96. package/dist/three-d/Models.d.ts.map +1 -1
  97. package/dist/three-d/Models.js +66 -3
  98. package/dist/three-d/Models.js.map +1 -1
  99. package/dist/two-d/render/ActorAnimator.d.ts +32 -0
  100. package/dist/two-d/render/ActorAnimator.d.ts.map +1 -1
  101. package/dist/two-d/render/ActorAnimator.js +21 -0
  102. package/dist/two-d/render/ActorAnimator.js.map +1 -1
  103. package/dist/two-d/render/AnimatedSprite.d.ts +24 -4
  104. package/dist/two-d/render/AnimatedSprite.d.ts.map +1 -1
  105. package/dist/two-d/render/AnimatedSprite.js +24 -4
  106. package/dist/two-d/render/AnimatedSprite.js.map +1 -1
  107. package/dist/two-d/render/Autotile.d.ts +33 -1
  108. package/dist/two-d/render/Autotile.d.ts.map +1 -1
  109. package/dist/two-d/render/Autotile.js +33 -1
  110. package/dist/two-d/render/Autotile.js.map +1 -1
  111. package/dist/two-d/render/Camera.d.ts +53 -1
  112. package/dist/two-d/render/Camera.d.ts.map +1 -1
  113. package/dist/two-d/render/Camera.js +36 -1
  114. package/dist/two-d/render/Camera.js.map +1 -1
  115. package/dist/two-d/render/Capabilities.d.ts +33 -0
  116. package/dist/two-d/render/Capabilities.d.ts.map +1 -1
  117. package/dist/two-d/render/Capabilities.js +33 -0
  118. package/dist/two-d/render/Capabilities.js.map +1 -1
  119. package/dist/two-d/render/ColorBlindness.d.ts +23 -0
  120. package/dist/two-d/render/ColorBlindness.d.ts.map +1 -1
  121. package/dist/two-d/render/ColorBlindness.js +23 -4
  122. package/dist/two-d/render/ColorBlindness.js.map +1 -1
  123. package/dist/two-d/render/ColorTransformBatcher.d.ts +67 -1
  124. package/dist/two-d/render/ColorTransformBatcher.d.ts.map +1 -1
  125. package/dist/two-d/render/ColorTransformBatcher.js +57 -1
  126. package/dist/two-d/render/ColorTransformBatcher.js.map +1 -1
  127. package/dist/two-d/render/LayeredSprite.d.ts +19 -0
  128. package/dist/two-d/render/LayeredSprite.d.ts.map +1 -1
  129. package/dist/two-d/render/LayeredSprite.js +19 -0
  130. package/dist/two-d/render/LayeredSprite.js.map +1 -1
  131. package/dist/two-d/render/Minimap.d.ts +25 -1
  132. package/dist/two-d/render/Minimap.d.ts.map +1 -1
  133. package/dist/two-d/render/Minimap.js +25 -1
  134. package/dist/two-d/render/Minimap.js.map +1 -1
  135. package/dist/two-d/render/Particles.d.ts +26 -2
  136. package/dist/two-d/render/Particles.d.ts.map +1 -1
  137. package/dist/two-d/render/Particles.js +23 -0
  138. package/dist/two-d/render/Particles.js.map +1 -1
  139. package/dist/two-d/render/Projectile.d.ts +14 -0
  140. package/dist/two-d/render/Projectile.d.ts.map +1 -1
  141. package/dist/two-d/render/Projectile.js +14 -0
  142. package/dist/two-d/render/Projectile.js.map +1 -1
  143. package/dist/two-d/render/ScreenEffects.d.ts +15 -0
  144. package/dist/two-d/render/ScreenEffects.d.ts.map +1 -1
  145. package/dist/two-d/render/ScreenEffects.js +15 -0
  146. package/dist/two-d/render/ScreenEffects.js.map +1 -1
  147. package/dist/two-d/render/Shape2D.d.ts +58 -1
  148. package/dist/two-d/render/Shape2D.d.ts.map +1 -1
  149. package/dist/two-d/render/Shape2D.js +58 -1
  150. package/dist/two-d/render/Shape2D.js.map +1 -1
  151. package/dist/two-d/render/StatusVisuals.d.ts +22 -0
  152. package/dist/two-d/render/StatusVisuals.d.ts.map +1 -1
  153. package/dist/two-d/render/StatusVisuals.js +22 -0
  154. package/dist/two-d/render/StatusVisuals.js.map +1 -1
  155. package/dist/two-d/render/TileMap.d.ts +65 -3
  156. package/dist/two-d/render/TileMap.d.ts.map +1 -1
  157. package/dist/two-d/render/TileMap.js +65 -3
  158. package/dist/two-d/render/TileMap.js.map +1 -1
  159. package/dist/two-d/render/TiledMap.d.ts +9 -3
  160. package/dist/two-d/render/TiledMap.d.ts.map +1 -1
  161. package/dist/two-d/render/TiledMap.js +9 -3
  162. package/dist/two-d/render/TiledMap.js.map +1 -1
  163. package/dist/two-d/render/TintedSprite.d.ts +9 -2
  164. package/dist/two-d/render/TintedSprite.d.ts.map +1 -1
  165. package/dist/two-d/render/TintedSprite.js +9 -2
  166. package/dist/two-d/render/TintedSprite.js.map +1 -1
  167. package/dist/two-d/render/Types2D.d.ts +14 -2
  168. package/dist/two-d/render/Types2D.d.ts.map +1 -1
  169. package/dist/two-d/render/Types2D.js +14 -2
  170. package/dist/two-d/render/Types2D.js.map +1 -1
  171. package/dist/two-d/render/Viewport.d.ts +22 -0
  172. package/dist/two-d/render/Viewport.d.ts.map +1 -1
  173. package/dist/two-d/render/Viewport.js +22 -0
  174. package/dist/two-d/render/Viewport.js.map +1 -1
  175. package/dist/two-d/ui/Bar.d.ts +16 -3
  176. package/dist/two-d/ui/Bar.d.ts.map +1 -1
  177. package/dist/two-d/ui/Bar.js +16 -1
  178. package/dist/two-d/ui/Bar.js.map +1 -1
  179. package/dist/two-d/ui/BitmapLabel.d.ts +26 -10
  180. package/dist/two-d/ui/BitmapLabel.d.ts.map +1 -1
  181. package/dist/two-d/ui/BitmapLabel.js +26 -3
  182. package/dist/two-d/ui/BitmapLabel.js.map +1 -1
  183. package/dist/two-d/ui/Button.d.ts +15 -0
  184. package/dist/two-d/ui/Button.d.ts.map +1 -1
  185. package/dist/two-d/ui/Button.js +15 -0
  186. package/dist/two-d/ui/Button.js.map +1 -1
  187. package/dist/two-d/ui/FloatingText.d.ts +15 -0
  188. package/dist/two-d/ui/FloatingText.d.ts.map +1 -1
  189. package/dist/two-d/ui/FloatingText.js +15 -0
  190. package/dist/two-d/ui/FloatingText.js.map +1 -1
  191. package/dist/two-d/ui/HelpScreen.d.ts +16 -0
  192. package/dist/two-d/ui/HelpScreen.d.ts.map +1 -1
  193. package/dist/two-d/ui/HelpScreen.js +23 -3
  194. package/dist/two-d/ui/HelpScreen.js.map +1 -1
  195. package/dist/two-d/ui/IconGrid.d.ts +27 -3
  196. package/dist/two-d/ui/IconGrid.d.ts.map +1 -1
  197. package/dist/two-d/ui/IconGrid.js +71 -55
  198. package/dist/two-d/ui/IconGrid.js.map +1 -1
  199. package/dist/two-d/ui/Label.d.ts +12 -8
  200. package/dist/two-d/ui/Label.d.ts.map +1 -1
  201. package/dist/two-d/ui/Label.js +14 -3
  202. package/dist/two-d/ui/Label.js.map +1 -1
  203. package/dist/two-d/ui/ListView.d.ts +22 -4
  204. package/dist/two-d/ui/ListView.d.ts.map +1 -1
  205. package/dist/two-d/ui/ListView.js +44 -43
  206. package/dist/two-d/ui/ListView.js.map +1 -1
  207. package/dist/two-d/ui/LoadingScreen.d.ts +24 -1
  208. package/dist/two-d/ui/LoadingScreen.d.ts.map +1 -1
  209. package/dist/two-d/ui/LoadingScreen.js +24 -1
  210. package/dist/two-d/ui/LoadingScreen.js.map +1 -1
  211. package/dist/two-d/ui/MessageBox.d.ts +21 -2
  212. package/dist/two-d/ui/MessageBox.d.ts.map +1 -1
  213. package/dist/two-d/ui/MessageBox.js +19 -0
  214. package/dist/two-d/ui/MessageBox.js.map +1 -1
  215. package/dist/two-d/ui/NinePatch.d.ts +12 -0
  216. package/dist/two-d/ui/NinePatch.d.ts.map +1 -1
  217. package/dist/two-d/ui/NinePatch.js +12 -0
  218. package/dist/two-d/ui/NinePatch.js.map +1 -1
  219. package/dist/two-d/ui/RebindScreen.d.ts +15 -0
  220. package/dist/two-d/ui/RebindScreen.d.ts.map +1 -1
  221. package/dist/two-d/ui/RebindScreen.js +15 -0
  222. package/dist/two-d/ui/RebindScreen.js.map +1 -1
  223. package/dist/two-d/ui/SelectionModel.d.ts +50 -0
  224. package/dist/two-d/ui/SelectionModel.d.ts.map +1 -0
  225. package/dist/two-d/ui/SelectionModel.js +73 -0
  226. package/dist/two-d/ui/SelectionModel.js.map +1 -0
  227. package/dist/two-d/ui/StatsScreen.d.ts +15 -0
  228. package/dist/two-d/ui/StatsScreen.d.ts.map +1 -1
  229. package/dist/two-d/ui/StatsScreen.js +15 -0
  230. package/dist/two-d/ui/StatsScreen.js.map +1 -1
  231. package/dist/two-d/ui/Toast.d.ts +12 -0
  232. package/dist/two-d/ui/Toast.d.ts.map +1 -1
  233. package/dist/two-d/ui/Toast.js +12 -0
  234. package/dist/two-d/ui/Toast.js.map +1 -1
  235. package/dist/two-d/ui/Tooltip.d.ts +14 -0
  236. package/dist/two-d/ui/Tooltip.d.ts.map +1 -1
  237. package/dist/two-d/ui/Tooltip.js +14 -0
  238. package/dist/two-d/ui/Tooltip.js.map +1 -1
  239. package/dist/two-d/ui/VerticalLabel.d.ts +18 -0
  240. package/dist/two-d/ui/VerticalLabel.d.ts.map +1 -1
  241. package/dist/two-d/ui/VerticalLabel.js +18 -0
  242. package/dist/two-d/ui/VerticalLabel.js.map +1 -1
  243. package/dist/two-d/ui/Window.d.ts +12 -0
  244. package/dist/two-d/ui/Window.d.ts.map +1 -1
  245. package/dist/two-d/ui/Window.js +12 -0
  246. package/dist/two-d/ui/Window.js.map +1 -1
  247. package/dist/two-d/ui/theme.d.ts +45 -1
  248. package/dist/two-d/ui/theme.d.ts.map +1 -1
  249. package/dist/two-d/ui/theme.js +45 -1
  250. package/dist/two-d/ui/theme.js.map +1 -1
  251. package/dist/two-d/ui/themedText.d.ts +20 -0
  252. package/dist/two-d/ui/themedText.d.ts.map +1 -0
  253. package/dist/two-d/ui/themedText.js +9 -0
  254. package/dist/two-d/ui/themedText.js.map +1 -0
  255. package/dist/version.d.ts +1 -1
  256. package/dist/version.js +1 -1
  257. package/package.json +11 -2
  258. package/tools/compile-resources.mjs +1 -1
  259. package/tools/compress-dist.d.mts +16 -0
  260. package/tools/compress-dist.mjs +116 -0
@@ -0,0 +1,151 @@
1
+ import type { Catalog, MessageValue } from './index.ts';
2
+ /**
3
+ * A catalog message reduced to plain, comparable text: a string as-is, a `PluralForms`
4
+ * reduced to its `other` branch (or the first form present, the same fallback
5
+ * `resolvePlural` itself uses with no count), and a `FluentMessage` formatted with no
6
+ * params - best-effort, since a `.ftl` message needing a required variable throws rather
7
+ * than resolving; that failure reads as empty text here rather than aborting the caller's
8
+ * whole scan.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { messageText } from '@datamoc/mw_games/i18n';
13
+ *
14
+ * messageText('Hello'); // 'Hello'
15
+ * messageText({ one: '1 item', other: '{count} items' }); // '{count} items'
16
+ * ```
17
+ */
18
+ export declare function messageText(value: MessageValue): string;
19
+ /**
20
+ * The classic edit distance: how many single-character insertions, deletions or
21
+ * substitutions turn `a` into `b`. The primitive `findSimilarMessages` is built on, exposed
22
+ * on its own since "how different are these two strings" is useful wherever a catalog's own
23
+ * message text is not the only thing worth comparing.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { levenshteinDistance } from '@datamoc/mw_games/i18n';
28
+ *
29
+ * levenshteinDistance('kitten', 'sitting'); // 3
30
+ * levenshteinDistance('same', 'same'); // 0
31
+ * ```
32
+ */
33
+ export declare function levenshteinDistance(a: string, b: string): number;
34
+ export interface SimilarMessagePair {
35
+ a: string;
36
+ b: string;
37
+ distance: number;
38
+ /** 1 minus the distance normalised by the longer message's length; 1 is identical text */
39
+ similarity: number;
40
+ }
41
+ /**
42
+ * Every pair of keys in `catalog` whose message text is at least `minSimilarity` alike
43
+ * (default 0.8), surfaced for a human to decide whether they are genuinely the same message
44
+ * translated three separate times - `mwg` finds the candidates, never merges anything on
45
+ * its own. Empty messages are skipped (nothing to compare), and pairs are sorted most
46
+ * similar first.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { findSimilarMessages } from '@datamoc/mw_games/i18n';
51
+ *
52
+ * const catalog = {
53
+ * locale: 'en', direction: 'ltr' as const,
54
+ * messages: { 'confirm.quit': 'Are you sure?', 'confirm.delete': 'Are you sure?' },
55
+ * };
56
+ *
57
+ * findSimilarMessages(catalog); // [{ a: 'confirm.quit', b: 'confirm.delete', distance: 0, similarity: 1 }]
58
+ * ```
59
+ */
60
+ export declare function findSimilarMessages(catalog: Catalog, minSimilarity?: number): SimilarMessagePair[];
61
+ export interface CatalogUsageStats {
62
+ totalKeys: number;
63
+ usedKeys: number;
64
+ /** present in the catalog but absent from `referencedKeys` - a candidate for deletion */
65
+ unusedKeys: readonly string[];
66
+ }
67
+ /**
68
+ * Which of a catalog's keys a game's own source actually references, and which just sit
69
+ * there. `mwg` has no idea how a game's code names a message key (a string literal, a
70
+ * generated constant, a `SemanticMessage.type`) - `referencedKeys` is however the caller
71
+ * already found that out (typically a grep or a build-time scan over its own source), the
72
+ * same boundary `rollRoster` draws around a game's own roster values.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { catalogUsage } from '@datamoc/mw_games/i18n';
77
+ *
78
+ * const catalog = {
79
+ * locale: 'en', direction: 'ltr' as const,
80
+ * messages: { greeting: 'Hi', unused: 'never shown' },
81
+ * };
82
+ *
83
+ * catalogUsage(catalog, ['greeting']); // { totalKeys: 2, usedKeys: 1, unusedKeys: ['unused'] }
84
+ * ```
85
+ */
86
+ export declare function catalogUsage(catalog: Catalog, referencedKeys: Iterable<string>): CatalogUsageStats;
87
+ /**
88
+ * How complete `other` is against `reference`, as a 0-1 fraction of `reference`'s own keys
89
+ * that `other` also has - built on `diffCatalogKeys` rather than recomputing the same set
90
+ * difference, so the two never disagree about what "missing" means.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { catalogCompleteness } from '@datamoc/mw_games/i18n';
95
+ *
96
+ * const en = { locale: 'en', direction: 'ltr' as const, messages: { a: '1', b: '2' } };
97
+ * const fr = { locale: 'fr', direction: 'ltr' as const, messages: { a: '1' } };
98
+ *
99
+ * catalogCompleteness(en, fr); // 0.5
100
+ * ```
101
+ */
102
+ export declare function catalogCompleteness(reference: Catalog, other: Catalog): number;
103
+ export interface PluralCoverage {
104
+ /** how many keys in the catalog are plural forms at all, rather than a plain string or a Fluent message */
105
+ pluralKeys: number;
106
+ /** how many plural-form keys define each CLDR category, `'other'` included */
107
+ formsPresent: Partial<Record<Intl.LDMLPluralRule, number>>;
108
+ }
109
+ /**
110
+ * How many of a catalog's plural-form messages define each CLDR category - `'few'`/`'many'`
111
+ * sitting at 0 while `'other'` covers every key is exactly the gap a language needing those
112
+ * categories (Polish, Arabic) would otherwise only discover once a player hit the wrong count.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * import { pluralFormCoverage } from '@datamoc/mw_games/i18n';
117
+ *
118
+ * const catalog = {
119
+ * locale: 'en', direction: 'ltr' as const,
120
+ * messages: { items: { one: '{count} item', other: '{count} items' } },
121
+ * };
122
+ *
123
+ * pluralFormCoverage(catalog); // { pluralKeys: 1, formsPresent: { one: 1, other: 1 } }
124
+ * ```
125
+ */
126
+ export declare function pluralFormCoverage(catalog: Catalog): PluralCoverage;
127
+ /**
128
+ * Drops `mergedKey` from `catalog`, keeping `survivingKey` (and its current text) exactly as
129
+ * it was - the mechanical half of collapsing two keys a human decided are the same message.
130
+ * Apply this to every language's own catalog to merge consistently across all of them.
131
+ *
132
+ * Rewriting whichever call sites used `mergedKey` is deliberately not this function's job:
133
+ * `mwg` has no view into a game's own source tree, the same boundary `catalogUsage`'s
134
+ * `referencedKeys` already draws - a caller doing that rewrite already knows exactly where
135
+ * `mergedKey` is used, since it had to find `referencedKeys` the same way to begin with.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * import { mergeCatalogKeys } from '@datamoc/mw_games/i18n';
140
+ *
141
+ * const catalog = {
142
+ * locale: 'en', direction: 'ltr' as const,
143
+ * messages: { 'confirm.quit': 'Are you sure?', 'confirm.delete': 'Are you sure?' },
144
+ * };
145
+ *
146
+ * const merged = mergeCatalogKeys(catalog, 'confirm.quit', 'confirm.delete');
147
+ * console.log(Object.keys(merged.messages)); // ['confirm.quit']
148
+ * ```
149
+ */
150
+ export declare function mergeCatalogKeys(catalog: Catalog, survivingKey: string, mergedKey: string): Catalog;
151
+ //# sourceMappingURL=Content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.d.ts","sourceRoot":"","sources":["../../src/i18n/Content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGxD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAWvD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBhE;AAED,MAAM,WAAW,kBAAkB;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,SAAM,GAAG,kBAAkB,EAAE,CAkB/F;AAED,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAKlG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAM9E;AAED,MAAM,WAAW,cAAc;IAC9B,2GAA2G;IAC3G,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAanE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAcnG"}
@@ -0,0 +1,219 @@
1
+ import { diffCatalogKeys } from './Validate.js';
2
+ /**
3
+ * A catalog message reduced to plain, comparable text: a string as-is, a `PluralForms`
4
+ * reduced to its `other` branch (or the first form present, the same fallback
5
+ * `resolvePlural` itself uses with no count), and a `FluentMessage` formatted with no
6
+ * params - best-effort, since a `.ftl` message needing a required variable throws rather
7
+ * than resolving; that failure reads as empty text here rather than aborting the caller's
8
+ * whole scan.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { messageText } from '@datamoc/mw_games/i18n';
13
+ *
14
+ * messageText('Hello'); // 'Hello'
15
+ * messageText({ one: '1 item', other: '{count} items' }); // '{count} items'
16
+ * ```
17
+ */
18
+ export function messageText(value) {
19
+ if (typeof value === 'string')
20
+ return value;
21
+ if (typeof value === 'object' && value !== null && 'format' in value) {
22
+ try {
23
+ return value.format();
24
+ }
25
+ catch {
26
+ return '';
27
+ }
28
+ }
29
+ const forms = value;
30
+ return forms.other ?? Object.values(forms)[0] ?? '';
31
+ }
32
+ /**
33
+ * The classic edit distance: how many single-character insertions, deletions or
34
+ * substitutions turn `a` into `b`. The primitive `findSimilarMessages` is built on, exposed
35
+ * on its own since "how different are these two strings" is useful wherever a catalog's own
36
+ * message text is not the only thing worth comparing.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { levenshteinDistance } from '@datamoc/mw_games/i18n';
41
+ *
42
+ * levenshteinDistance('kitten', 'sitting'); // 3
43
+ * levenshteinDistance('same', 'same'); // 0
44
+ * ```
45
+ */
46
+ export function levenshteinDistance(a, b) {
47
+ if (a === b)
48
+ return 0;
49
+ if (a.length === 0)
50
+ return b.length;
51
+ if (b.length === 0)
52
+ return a.length;
53
+ let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
54
+ let current = new Array(b.length + 1);
55
+ for (let i = 1; i <= a.length; i++) {
56
+ current[0] = i;
57
+ for (let j = 1; j <= b.length; j++) {
58
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
59
+ current[j] = Math.min(previous[j] + 1, //deletion
60
+ current[j - 1] + 1, //insertion
61
+ previous[j - 1] + cost //substitution
62
+ );
63
+ }
64
+ [previous, current] = [current, previous];
65
+ }
66
+ return previous[b.length];
67
+ }
68
+ /**
69
+ * Every pair of keys in `catalog` whose message text is at least `minSimilarity` alike
70
+ * (default 0.8), surfaced for a human to decide whether they are genuinely the same message
71
+ * translated three separate times - `mwg` finds the candidates, never merges anything on
72
+ * its own. Empty messages are skipped (nothing to compare), and pairs are sorted most
73
+ * similar first.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { findSimilarMessages } from '@datamoc/mw_games/i18n';
78
+ *
79
+ * const catalog = {
80
+ * locale: 'en', direction: 'ltr' as const,
81
+ * messages: { 'confirm.quit': 'Are you sure?', 'confirm.delete': 'Are you sure?' },
82
+ * };
83
+ *
84
+ * findSimilarMessages(catalog); // [{ a: 'confirm.quit', b: 'confirm.delete', distance: 0, similarity: 1 }]
85
+ * ```
86
+ */
87
+ export function findSimilarMessages(catalog, minSimilarity = 0.8) {
88
+ const entries = Object.entries(catalog.messages)
89
+ .map(([key, value]) => [key, messageText(value)])
90
+ .filter(([, text]) => text.length > 0);
91
+ const pairs = [];
92
+ for (let i = 0; i < entries.length; i++) {
93
+ for (let j = i + 1; j < entries.length; j++) {
94
+ const [keyA, textA] = entries[i];
95
+ const [keyB, textB] = entries[j];
96
+ const maxLen = Math.max(textA.length, textB.length);
97
+ const distance = levenshteinDistance(textA, textB);
98
+ const similarity = maxLen === 0 ? 1 : 1 - distance / maxLen;
99
+ if (similarity >= minSimilarity)
100
+ pairs.push({ a: keyA, b: keyB, distance, similarity });
101
+ }
102
+ }
103
+ return pairs.sort((x, y) => y.similarity - x.similarity);
104
+ }
105
+ /**
106
+ * Which of a catalog's keys a game's own source actually references, and which just sit
107
+ * there. `mwg` has no idea how a game's code names a message key (a string literal, a
108
+ * generated constant, a `SemanticMessage.type`) - `referencedKeys` is however the caller
109
+ * already found that out (typically a grep or a build-time scan over its own source), the
110
+ * same boundary `rollRoster` draws around a game's own roster values.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * import { catalogUsage } from '@datamoc/mw_games/i18n';
115
+ *
116
+ * const catalog = {
117
+ * locale: 'en', direction: 'ltr' as const,
118
+ * messages: { greeting: 'Hi', unused: 'never shown' },
119
+ * };
120
+ *
121
+ * catalogUsage(catalog, ['greeting']); // { totalKeys: 2, usedKeys: 1, unusedKeys: ['unused'] }
122
+ * ```
123
+ */
124
+ export function catalogUsage(catalog, referencedKeys) {
125
+ const referenced = new Set(referencedKeys);
126
+ const keys = Object.keys(catalog.messages);
127
+ const unusedKeys = keys.filter((key) => !referenced.has(key));
128
+ return { totalKeys: keys.length, usedKeys: keys.length - unusedKeys.length, unusedKeys };
129
+ }
130
+ /**
131
+ * How complete `other` is against `reference`, as a 0-1 fraction of `reference`'s own keys
132
+ * that `other` also has - built on `diffCatalogKeys` rather than recomputing the same set
133
+ * difference, so the two never disagree about what "missing" means.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * import { catalogCompleteness } from '@datamoc/mw_games/i18n';
138
+ *
139
+ * const en = { locale: 'en', direction: 'ltr' as const, messages: { a: '1', b: '2' } };
140
+ * const fr = { locale: 'fr', direction: 'ltr' as const, messages: { a: '1' } };
141
+ *
142
+ * catalogCompleteness(en, fr); // 0.5
143
+ * ```
144
+ */
145
+ export function catalogCompleteness(reference, other) {
146
+ const referenceKeys = Object.keys(reference.messages);
147
+ if (referenceKeys.length === 0)
148
+ return 1;
149
+ const { missing } = diffCatalogKeys(reference, other);
150
+ return (referenceKeys.length - missing.length) / referenceKeys.length;
151
+ }
152
+ /**
153
+ * How many of a catalog's plural-form messages define each CLDR category - `'few'`/`'many'`
154
+ * sitting at 0 while `'other'` covers every key is exactly the gap a language needing those
155
+ * categories (Polish, Arabic) would otherwise only discover once a player hit the wrong count.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * import { pluralFormCoverage } from '@datamoc/mw_games/i18n';
160
+ *
161
+ * const catalog = {
162
+ * locale: 'en', direction: 'ltr' as const,
163
+ * messages: { items: { one: '{count} item', other: '{count} items' } },
164
+ * };
165
+ *
166
+ * pluralFormCoverage(catalog); // { pluralKeys: 1, formsPresent: { one: 1, other: 1 } }
167
+ * ```
168
+ */
169
+ export function pluralFormCoverage(catalog) {
170
+ const formsPresent = {};
171
+ let pluralKeys = 0;
172
+ for (const value of Object.values(catalog.messages)) {
173
+ if (typeof value === 'string' || (typeof value === 'object' && value !== null && 'format' in value))
174
+ continue;
175
+ pluralKeys++;
176
+ for (const category of Object.keys(value)) {
177
+ formsPresent[category] = (formsPresent[category] ?? 0) + 1;
178
+ }
179
+ }
180
+ return { pluralKeys, formsPresent };
181
+ }
182
+ /**
183
+ * Drops `mergedKey` from `catalog`, keeping `survivingKey` (and its current text) exactly as
184
+ * it was - the mechanical half of collapsing two keys a human decided are the same message.
185
+ * Apply this to every language's own catalog to merge consistently across all of them.
186
+ *
187
+ * Rewriting whichever call sites used `mergedKey` is deliberately not this function's job:
188
+ * `mwg` has no view into a game's own source tree, the same boundary `catalogUsage`'s
189
+ * `referencedKeys` already draws - a caller doing that rewrite already knows exactly where
190
+ * `mergedKey` is used, since it had to find `referencedKeys` the same way to begin with.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { mergeCatalogKeys } from '@datamoc/mw_games/i18n';
195
+ *
196
+ * const catalog = {
197
+ * locale: 'en', direction: 'ltr' as const,
198
+ * messages: { 'confirm.quit': 'Are you sure?', 'confirm.delete': 'Are you sure?' },
199
+ * };
200
+ *
201
+ * const merged = mergeCatalogKeys(catalog, 'confirm.quit', 'confirm.delete');
202
+ * console.log(Object.keys(merged.messages)); // ['confirm.quit']
203
+ * ```
204
+ */
205
+ export function mergeCatalogKeys(catalog, survivingKey, mergedKey) {
206
+ if (!(survivingKey in catalog.messages)) {
207
+ throw new Error(`mergeCatalogKeys: "${survivingKey}" is not a key in this catalog`);
208
+ }
209
+ if (!(mergedKey in catalog.messages)) {
210
+ throw new Error(`mergeCatalogKeys: "${mergedKey}" is not a key in this catalog`);
211
+ }
212
+ if (survivingKey === mergedKey) {
213
+ throw new Error('mergeCatalogKeys: survivingKey and mergedKey must be different keys');
214
+ }
215
+ const messages = { ...catalog.messages };
216
+ delete messages[mergedKey];
217
+ return { ...catalog, messages };
218
+ }
219
+ //# sourceMappingURL=Content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Content.js","sourceRoot":"","sources":["../../src/i18n/Content.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,KAAmB;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QACtE,IAAI,CAAC;YACJ,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACvB,C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AAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,gCAAgC,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,QAAQ,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IACzC,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,OAAO,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC"}
@@ -85,11 +85,41 @@ export interface MessageParams {
85
85
  */
86
86
  export declare function t(key: string, params?: MessageParams): string;
87
87
  /**
88
- * Replaces apostrophes between letters for locales whose ordinary elisions use a curly
89
- * apostrophe. English and other locales are left untouched, as a straight apostrophe can
90
- * be intentional punctuation there.
88
+ * Locale-specific punctuation/spacing conventions, applied on top of interpolation - the
89
+ * things a translator would type by hand if this project asked every catalog to carry
90
+ * literal U+202F/U+00A0 characters, which no one would ever remember to do consistently.
91
+ *
92
+ * French (Imprimerie nationale's rules, `Lexique des règles typographiques`): a narrow
93
+ * no-break space before `; : ! ?` and around `« »`, and an ordinary no-break space between a
94
+ * numbering word and the number following it ("Chapitre 3"). Also replaces apostrophes
95
+ * between letters with a curly one, for French, Italian, and Dutch elisions - English and
96
+ * other locales are left untouched, as a straight apostrophe can be intentional punctuation
97
+ * there.
98
+ *
99
+ * German (Duden K 116/117): a no-break space between a number and its unit ("5 kg"), and
100
+ * after a small set of abbreviations before whatever follows ("Nr. 3", "Dr. Müller").
101
+ *
102
+ * Deliberately not attempted here: a *game's own* units ("pièces d'or", "points de vie") -
103
+ * `mwg` cannot know a game's vocabulary any more than it knows its item names, so gluing a
104
+ * value to a game-specific unit is `nonBreakingUnit`'s job, not this function's.
91
105
  */
92
106
  export declare function typographic(text: string, language?: string): string;
107
+ /** joins a value and its unit with whatever space French/German typography requires to keep
108
+ * them from breaking across a line - the unit's own text ("pièces d'or", "points de vie",
109
+ * "kg") is always the game's own vocabulary; this only picks the space that glues it to the
110
+ * value in front of it, the same division `SemanticMessage`/`EntityTextResolver` already draw
111
+ * between mechanism and content.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { nonBreakingUnit } from '@datamoc/mw_games/i18n';
116
+ *
117
+ * console.log(nonBreakingUnit(12, 'pièces d\'or', 'fr')); // '12 pièces d\'or'
118
+ * console.log(nonBreakingUnit(5, 'kg', 'de')); // '5 kg'
119
+ * console.log(nonBreakingUnit(3, 'gold', 'en')); // '3 gold'
120
+ * ```
121
+ */
122
+ export declare function nonBreakingUnit(value: string | number, unit: string, language?: string): string;
93
123
  /** true when `key` resolves to something other than itself, in either language */
94
124
  export declare function has(key: string): boolean;
95
125
  /** clears both languages, mainly so tests do not leak state into one another */
@@ -101,4 +131,6 @@ export type { SemanticMessage, EntityTextResolver, GrammaticalEntity, MessageCha
101
131
  export { formatNumber, formatDate, formatList } from './Format.ts';
102
132
  export { diffCatalogKeys, validateCatalog } from './Validate.ts';
103
133
  export type { CatalogKeyDiff, CatalogIssue } from './Validate.ts';
134
+ export { messageText, levenshteinDistance, findSimilarMessages, catalogUsage, catalogCompleteness, pluralFormCoverage, mergeCatalogKeys, } from './Content.ts';
135
+ export type { SimilarMessagePair, CatalogUsageStats, PluralCoverage } from './Content.ts';
104
136
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,6FAA6F;AAC7F,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,oFAAoF;AACpF,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE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B,EACnB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
@@ -93,15 +93,96 @@ export function t(key, params) {
93
93
  const PDI = '⁩'; // pop directional isolate
94
94
  return direction() === 'rtl' ? `${RLI}${resolved}${PDI}` : resolved;
95
95
  }
96
+ /** espace fine insécable - narrow no-break space, U+202F */
97
+ const THIN_NBSP = ' ';
98
+ /** espace insécable - ordinary no-break space, U+00A0 */
99
+ const NBSP = ' ';
100
+ /** words a French document commonly numbers - generic document/narrative structure, not any
101
+ * one game's own vocabulary, the same way `t()`'s plural categories are language structure
102
+ * rather than content */
103
+ const FR_NUMBERING_WORDS = [
104
+ 'Chapitre', 'Tome', 'Livre', 'Partie', 'Section', 'Article', 'Acte', 'Scène',
105
+ 'Niveau', 'Manche', 'Round', 'Étape', 'Volume', 'Figure', 'Page', 'Numéro',
106
+ ];
107
+ /** German abbreviations that keep a no-break space before whatever follows them (Duden K 116) */
108
+ const DE_ABBREVIATIONS = ['Nr', 'Dr', 'Bd', 'Kap', 'Art', 'Abb', 'Str', 'Tel'];
109
+ /** units a no-break space keeps glued to the number in front of them (Duden K 117) */
110
+ const DE_UNITS = ['kg', 'g', 'mg', 't', 'km', 'm', 'cm', 'mm', 'l', 'ml', 'h', 'min', 's', '%', '°C', '€'];
96
111
  /**
97
- * Replaces apostrophes between letters for locales whose ordinary elisions use a curly
98
- * apostrophe. English and other locales are left untouched, as a straight apostrophe can
99
- * be intentional punctuation there.
112
+ * Locale-specific punctuation/spacing conventions, applied on top of interpolation - the
113
+ * things a translator would type by hand if this project asked every catalog to carry
114
+ * literal U+202F/U+00A0 characters, which no one would ever remember to do consistently.
115
+ *
116
+ * French (Imprimerie nationale's rules, `Lexique des règles typographiques`): a narrow
117
+ * no-break space before `; : ! ?` and around `« »`, and an ordinary no-break space between a
118
+ * numbering word and the number following it ("Chapitre 3"). Also replaces apostrophes
119
+ * between letters with a curly one, for French, Italian, and Dutch elisions - English and
120
+ * other locales are left untouched, as a straight apostrophe can be intentional punctuation
121
+ * there.
122
+ *
123
+ * German (Duden K 116/117): a no-break space between a number and its unit ("5 kg"), and
124
+ * after a small set of abbreviations before whatever follows ("Nr. 3", "Dr. Müller").
125
+ *
126
+ * Deliberately not attempted here: a *game's own* units ("pièces d'or", "points de vie") -
127
+ * `mwg` cannot know a game's vocabulary any more than it knows its item names, so gluing a
128
+ * value to a game-specific unit is `nonBreakingUnit`'s job, not this function's.
100
129
  */
101
130
  export function typographic(text, language = locale()) {
102
- if (!/^(fr|it|nl)(?:-|$)/i.test(language))
103
- return text;
104
- return text.replace(/([\p{L}])'(?=[\p{L}])/gu, '$1’');
131
+ const lang = language.split('-')[0].toLowerCase();
132
+ let result = text;
133
+ if (lang === 'fr' || lang === 'it' || lang === 'nl') {
134
+ result = result.replace(/([\p{L}])'(?=[\p{L}])/gu, '$1’');
135
+ }
136
+ if (lang === 'fr')
137
+ result = frenchSpacing(result);
138
+ if (lang === 'de')
139
+ result = germanSpacing(result);
140
+ return result;
141
+ }
142
+ /** joins a value and its unit with whatever space French/German typography requires to keep
143
+ * them from breaking across a line - the unit's own text ("pièces d'or", "points de vie",
144
+ * "kg") is always the game's own vocabulary; this only picks the space that glues it to the
145
+ * value in front of it, the same division `SemanticMessage`/`EntityTextResolver` already draw
146
+ * between mechanism and content.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * import { nonBreakingUnit } from '@datamoc/mw_games/i18n';
151
+ *
152
+ * console.log(nonBreakingUnit(12, 'pièces d\'or', 'fr')); // '12 pièces d\'or'
153
+ * console.log(nonBreakingUnit(5, 'kg', 'de')); // '5 kg'
154
+ * console.log(nonBreakingUnit(3, 'gold', 'en')); // '3 gold'
155
+ * ```
156
+ */
157
+ export function nonBreakingUnit(value, unit, language = locale()) {
158
+ const lang = language.split('-')[0].toLowerCase();
159
+ const space = lang === 'fr' ? THIN_NBSP : lang === 'de' ? NBSP : ' ';
160
+ return `${value}${space}${unit}`;
161
+ }
162
+ /** idempotent on purpose: `\s` already matches U+202F/U+00A0, so re-running this on
163
+ * already-spaced text leaves it unchanged rather than stacking a second space */
164
+ function frenchSpacing(text) {
165
+ let result = text
166
+ .replace(/\s?([;!?])/g, `${THIN_NBSP}$1`)
167
+ .replace(/«\s?/g, `«${THIN_NBSP}`)
168
+ .replace(/\s?»/g, `${THIN_NBSP}»`);
169
+ // `:` is excluded from clock times ("12:30") and URLs ("https://") by requiring a letter,
170
+ // not a digit, immediately before it - a heuristic good enough for translated dialogue/UI
171
+ // text, not a general-purpose text parser
172
+ result = result.replace(/(\p{L})\s?:/gu, `$1${THIN_NBSP}:`);
173
+ const numbering = new RegExp(`\\b(${FR_NUMBERING_WORDS.join('|')})\\s+(?=\\d)`, 'g');
174
+ return result.replace(numbering, `$1${NBSP}`);
175
+ }
176
+ function germanSpacing(text) {
177
+ // `\b` after a symbol like `%`/`€` never matches (neither side of that boundary is a "word"
178
+ // character), so the next-character check is spelled out directly instead: not a letter or
179
+ // digit, which also rules out matching "kg" as a false-positive prefix of a longer word
180
+ const units = new RegExp(`(\\d)\\s+(?=(?:${DE_UNITS.map(escapeRegExp).join('|')})(?![\\p{L}\\p{N}]))`, 'gu');
181
+ const abbreviations = new RegExp(`\\b(${DE_ABBREVIATIONS.join('|')})\\.\\s+`, 'g');
182
+ return text.replace(units, `$1${NBSP}`).replace(abbreviations, `$1.${NBSP}`);
183
+ }
184
+ function escapeRegExp(literal) {
185
+ return literal.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
105
186
  }
106
187
  /** true when `key` resolves to something other than itself, in either language */
107
188
  export function has(key) {
@@ -133,4 +214,5 @@ export { parseFTL } from './Fluent.js';
133
214
  export { createCatalogFormatter } from './SemanticMessage.js';
134
215
  export { formatNumber, formatDate, formatList } from './Format.js';
135
216
  export { diffCatalogKeys, validateCatalog } from './Validate.js';
217
+ export { messageText, levenshteinDistance, findSimilarMessages, catalogUsage, catalogCompleteness, pluralFormCoverage, mergeCatalogKeys, } from './Content.js';
136
218
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAuBH,IAAI,IAAI,GAAmB,IAAI,CAAC;AAChC,IAAI,MAAM,GAAmB,IAAI,CAAC;AAClC,IAAI,WAAW,GAA4B,IAAI,CAAC;AAChD,IAAI,aAAa,GAA4B,IAAI,CAAC;AAElD,uEAAuE;AACvE,MAAM,UAAU,OAAO,CAAC,OAAgB;IACvC,IAAI,GAAG,OAAO,CAAC;AAChB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,SAAS,CAAC,OAAuB;IAChD,MAAM,GAAG,OAAO,CAAC;IACjB,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,MAAM;IACrB,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,MAAM,IAAI,IAAI,CAAC;AACzC,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,SAAS;IACxB,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,SAAS,IAAI,KAAK,CAAC;AAC7C,CAAC;AAQD;;;;;;GAMG;AACH,MAAM,UAAU,CAAC,CAAC,GAAW,EAAE,MAAsB;IACpD,MAAM,KAAK,GAAG,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAEpC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,Q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