@gram-lang/i18n 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -34,6 +34,15 @@ declare const UNIT_CONVERSIONS: {
34
34
  * Examples: 'càs' -> 'tbsp', 'kilo' -> 'kg'.
35
35
  */
36
36
  declare function normalizeUnit(rawUnit: string | undefined | null, lang?: string): string;
37
+ /**
38
+ * True for a mass/volume unit at or above its category's base unit (g, kg,
39
+ * oz, lb, ml, cl, dl, l, tsp, tbsp, cup, ...) — the kind of unit a cook
40
+ * measures with a scale or a spoon, not a lab balance. Callers use this to
41
+ * decide when a quantity should be rounded coarser for display than the
42
+ * precision it's stored at. Sub-base units (mg, drop, smidgen, pinch, dash)
43
+ * return false since their values are already small.
44
+ */
45
+ declare function isCoarseUnit(rawUnit: string | undefined | null): boolean;
37
46
 
38
47
  declare function getAiLanguageInstruction(lang?: string): string;
39
48
 
@@ -102,6 +111,7 @@ declare const en: {
102
111
  purchasingWeight: string;
103
112
  gross: string;
104
113
  intermediateResult: string;
114
+ moduleFrom: string;
105
115
  estimatedSuffix: string;
106
116
  missingMass: string;
107
117
  someIngredients: string;
@@ -183,16 +193,45 @@ declare const en: {
183
193
  massDesc: string;
184
194
  yieldManagement: string;
185
195
  nutrition: string;
196
+ stockTitle: string;
197
+ stockDesc: string;
186
198
  };
187
199
  output: {
188
200
  copy: string;
189
201
  loading: string;
190
202
  };
191
203
  warnings: {
204
+ consoleTitle: string;
205
+ errors: string;
206
+ error: string;
192
207
  warnings: string;
193
208
  warning: string;
209
+ infos: string;
210
+ info: string;
194
211
  item: string;
195
212
  show: string;
213
+ expandConsole: string;
214
+ collapseConsole: string;
215
+ };
216
+ errorState: {
217
+ title: string;
218
+ blockingDescription: string;
219
+ jumpToError: string;
220
+ line: string;
221
+ };
222
+ tabs: {
223
+ addFile: string;
224
+ removeFile: string;
225
+ renameFile: string;
226
+ entryFile: string;
227
+ newFileName: string;
228
+ previewingStandalone: string;
229
+ openFiles: string;
230
+ hasErrors: string;
231
+ };
232
+ mobileTabs: {
233
+ editor: string;
234
+ preview: string;
196
235
  };
197
236
  analysisOptions: string;
198
237
  analysis: string;
@@ -208,4 +247,4 @@ type GramLocale = typeof en;
208
247
 
209
248
  declare function getDictionary(lang?: string): GramLocale;
210
249
 
211
- export { CATEGORY_KEYS, type CategoryKey, type CompiledDict, type GramLocale, type LanguageDict, TIME_BY_LANG, TIME_DICTIONARIES, TIME_GLOBAL, TIME_TO_MINUTES, UNIT_BY_LANG, UNIT_CONVERSIONS, UNIT_DICTIONARIES, UNIT_GLOBAL, type UnitMap, compileDictionary, getAiLanguageInstruction, getCategoryLabels, getDefaultCategories, getDictionary, isCategoryKey, normalizeUnit, resolveTimeUnit };
250
+ export { CATEGORY_KEYS, type CategoryKey, type CompiledDict, type GramLocale, type LanguageDict, TIME_BY_LANG, TIME_DICTIONARIES, TIME_GLOBAL, TIME_TO_MINUTES, UNIT_BY_LANG, UNIT_CONVERSIONS, UNIT_DICTIONARIES, UNIT_GLOBAL, type UnitMap, compileDictionary, getAiLanguageInstruction, getCategoryLabels, getDefaultCategories, getDictionary, isCategoryKey, isCoarseUnit, normalizeUnit, resolveTimeUnit };
package/dist/index.js CHANGED
@@ -184,6 +184,15 @@ function normalizeUnit(rawUnit, lang) {
184
184
  }
185
185
  return UNIT_GLOBAL[clean] || clean;
186
186
  }
187
+ function isCoarseUnit(rawUnit) {
188
+ const normalized = normalizeUnit(rawUnit);
189
+ if (!normalized) return false;
190
+ for (const category of [UNIT_CONVERSIONS.mass, UNIT_CONVERSIONS.volume]) {
191
+ const factor = category.map[normalized];
192
+ if (factor !== void 0) return factor >= 1;
193
+ }
194
+ return false;
195
+ }
187
196
 
188
197
  // src/ai.ts
189
198
  var LANGUAGE_NAMES = {
@@ -314,6 +323,7 @@ var en3 = {
314
323
  purchasingWeight: "Purchasing Weight (including waste/peel)",
315
324
  gross: "gross",
316
325
  intermediateResult: "Intermediate result for this section",
326
+ moduleFrom: "From this module",
317
327
  estimatedSuffix: " (Estimated)",
318
328
  missingMass: " (Missing: ",
319
329
  someIngredients: "some ingredients",
@@ -406,17 +416,46 @@ var en3 = {
406
416
  massStandardization: "Mass Standardization",
407
417
  massDesc: "Converts all ingredient quantities into grams.",
408
418
  yieldManagement: "Yield Management",
409
- nutrition: "Nutrition Estimation"
419
+ nutrition: "Nutrition Estimation",
420
+ stockTitle: "Stock (skip steps)",
421
+ stockDesc: "Treat as already on hand \u2014 collapses to one shopping-list line, no timeline steps."
410
422
  },
411
423
  output: {
412
424
  copy: "Copy to clipboard",
413
425
  loading: "Loading viewer..."
414
426
  },
415
427
  warnings: {
428
+ consoleTitle: "Diagnostics & Debug",
429
+ errors: "Errors",
430
+ error: "Error",
416
431
  warnings: "Warnings",
417
432
  warning: "Warning",
433
+ infos: "Notices",
434
+ info: "Notice",
418
435
  item: "Item",
419
- show: "Show"
436
+ show: "Show",
437
+ expandConsole: "Expand console",
438
+ collapseConsole: "Collapse console"
439
+ },
440
+ errorState: {
441
+ title: "Generation paused",
442
+ blockingDescription: "The recipe contains blocking errors preventing preview generation.",
443
+ jumpToError: "Jump to error",
444
+ line: "Line"
445
+ },
446
+ tabs: {
447
+ addFile: "Add file",
448
+ removeFile: "Remove file",
449
+ renameFile: "Rename file",
450
+ entryFile: "Entry",
451
+ newFileName: "New file name",
452
+ previewingStandalone: "Standalone preview of",
453
+ openFiles: "Open files",
454
+ hasErrors: "has errors"
455
+ },
456
+ mobileTabs: {
457
+ editor: "Editor",
458
+ preview: "Preview"
420
459
  },
421
460
  analysisOptions: "Analysis Options",
422
461
  analysis: "Analysis",
@@ -476,6 +515,7 @@ var fr3 = {
476
515
  purchasingWeight: "Poids d'achat (incluant d\xE9chets/\xE9pluchures)",
477
516
  gross: "brut",
478
517
  intermediateResult: "R\xE9sultat interm\xE9diaire pour cette section",
518
+ moduleFrom: "Depuis ce module",
479
519
  estimatedSuffix: " (Estim\xE9)",
480
520
  missingMass: " (Manquant : ",
481
521
  someIngredients: "certains ingr\xE9dients",
@@ -556,17 +596,46 @@ var fr3 = {
556
596
  massStandardization: "Standardisation des masses",
557
597
  massDesc: "Convertit toutes les quantit\xE9s d'ingr\xE9dients en grammes.",
558
598
  yieldManagement: "Gestion du rendement",
559
- nutrition: "Estimation nutritionnelle"
599
+ nutrition: "Estimation nutritionnelle",
600
+ stockTitle: "En stock (masquer les \xE9tapes)",
601
+ stockDesc: "Consid\xE9r\xE9 comme d\xE9j\xE0 disponible \u2014 se r\xE9duit \xE0 une ligne d'achat, sans \xE9tapes sur la frise."
560
602
  },
561
603
  output: {
562
604
  copy: "Copier dans le presse-papier",
563
605
  loading: "Chargement du lecteur..."
564
606
  },
565
607
  warnings: {
608
+ consoleTitle: "Diagnostics & D\xE9bogage",
609
+ errors: "Erreurs",
610
+ error: "Erreur",
566
611
  warnings: "Avertissements",
567
612
  warning: "Avertissement",
613
+ infos: "Informations",
614
+ info: "Information",
568
615
  item: "\xC9l\xE9ment",
569
- show: "Afficher"
616
+ show: "Afficher",
617
+ expandConsole: "D\xE9velopper la console",
618
+ collapseConsole: "R\xE9duire la console"
619
+ },
620
+ errorState: {
621
+ title: "G\xE9n\xE9ration interrompue",
622
+ blockingDescription: "La recette contient des erreurs bloquantes emp\xEAchant la g\xE9n\xE9ration de l'aper\xE7u.",
623
+ jumpToError: "Aller \xE0 l'erreur",
624
+ line: "Ligne"
625
+ },
626
+ tabs: {
627
+ addFile: "Ajouter un fichier",
628
+ removeFile: "Supprimer le fichier",
629
+ renameFile: "Renommer le fichier",
630
+ entryFile: "Entr\xE9e",
631
+ newFileName: "Nom du nouveau fichier",
632
+ previewingStandalone: "Aper\xE7u isol\xE9 de",
633
+ openFiles: "Fichiers ouverts",
634
+ hasErrors: "contient des erreurs"
635
+ },
636
+ mobileTabs: {
637
+ editor: "\xC9diteur",
638
+ preview: "Aper\xE7u"
570
639
  },
571
640
  analysisOptions: "Options d'Analyse",
572
641
  analysis: "Analyse",
@@ -605,6 +674,7 @@ export {
605
674
  getDefaultCategories,
606
675
  getDictionary,
607
676
  isCategoryKey,
677
+ isCoarseUnit,
608
678
  normalizeUnit,
609
679
  resolveTimeUnit
610
680
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gram-lang/i18n",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Gram recipe i18n and unit normalization logic",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm --dts --tsconfig ../../tsconfig.build.json",
33
33
  "typecheck": "tsc --noEmit",
34
- "test": "bun test",
34
+ "test": "bun test --only-failures",
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "type": "module"