@gram-lang/i18n 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +58 -1
- package/dist/index.js +124 -6
- package/package.json +2 -2
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,9 +111,30 @@ 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;
|
|
118
|
+
nutritionWholeRecipe: string;
|
|
119
|
+
nutritionPerPortion: string;
|
|
120
|
+
nutritionPer100g: string;
|
|
121
|
+
nutritionRawMassNote: string;
|
|
122
|
+
nutritionRawMassNotePartial: string;
|
|
123
|
+
incompleteData: string;
|
|
124
|
+
ofWhich: string;
|
|
125
|
+
nutrients: {
|
|
126
|
+
calories: string;
|
|
127
|
+
fat: string;
|
|
128
|
+
sat_fat: string;
|
|
129
|
+
mono_fat: string;
|
|
130
|
+
poly_fat: string;
|
|
131
|
+
carbs: string;
|
|
132
|
+
sugar: string;
|
|
133
|
+
fiber: string;
|
|
134
|
+
protein: string;
|
|
135
|
+
sodium: string;
|
|
136
|
+
alcohol: string;
|
|
137
|
+
};
|
|
108
138
|
};
|
|
109
139
|
playground: {
|
|
110
140
|
title: string;
|
|
@@ -163,16 +193,43 @@ declare const en: {
|
|
|
163
193
|
massDesc: string;
|
|
164
194
|
yieldManagement: string;
|
|
165
195
|
nutrition: string;
|
|
196
|
+
stockTitle: string;
|
|
197
|
+
stockDesc: string;
|
|
166
198
|
};
|
|
167
199
|
output: {
|
|
168
200
|
copy: string;
|
|
169
201
|
loading: string;
|
|
170
202
|
};
|
|
171
203
|
warnings: {
|
|
204
|
+
consoleTitle: string;
|
|
205
|
+
errors: string;
|
|
206
|
+
error: string;
|
|
172
207
|
warnings: string;
|
|
173
208
|
warning: string;
|
|
209
|
+
infos: string;
|
|
210
|
+
info: string;
|
|
174
211
|
item: string;
|
|
175
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
|
+
};
|
|
230
|
+
mobileTabs: {
|
|
231
|
+
editor: string;
|
|
232
|
+
preview: string;
|
|
176
233
|
};
|
|
177
234
|
analysisOptions: string;
|
|
178
235
|
analysis: string;
|
|
@@ -188,4 +245,4 @@ type GramLocale = typeof en;
|
|
|
188
245
|
|
|
189
246
|
declare function getDictionary(lang?: string): GramLocale;
|
|
190
247
|
|
|
191
|
-
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 };
|
|
248
|
+
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,9 +323,42 @@ 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
|
-
someIngredients: "some ingredients"
|
|
329
|
+
someIngredients: "some ingredients",
|
|
330
|
+
// Nutrition bases. Which one is shown is the renderer's
|
|
331
|
+
// `nutritionBasis` option; the analyzer computes all three.
|
|
332
|
+
nutritionWholeRecipe: "Whole recipe",
|
|
333
|
+
nutritionPerPortion: "Per portion",
|
|
334
|
+
nutritionPer100g: "Per 100 g",
|
|
335
|
+
// Gram models no cooking loss, so a per-100 g figure is per 100 g of
|
|
336
|
+
// the raw assembled mixture — said plainly rather than left implied.
|
|
337
|
+
// The partial variant is used as soon as some ingredient lacks
|
|
338
|
+
// nutrition data, because the mass then covers only what was counted
|
|
339
|
+
// and not the whole recipe; hedging that way when everything *is*
|
|
340
|
+
// covered would only weaken the message.
|
|
341
|
+
nutritionRawMassNote: "Based on {mass} of ingredients, before cooking",
|
|
342
|
+
nutritionRawMassNotePartial: "Based on the {mass} with nutrition data, before cooking",
|
|
343
|
+
incompleteData: "Incomplete data",
|
|
344
|
+
// One entry per key in @gram-lang/analyzer's NUTRIENTS table; the
|
|
345
|
+
// renderer test asserts the two stay in step. A sub-macro's label is
|
|
346
|
+
// prefixed with `ofWhich` at display time rather than baked in here,
|
|
347
|
+
// so the same string works standalone and nested.
|
|
348
|
+
ofWhich: "of which",
|
|
349
|
+
nutrients: {
|
|
350
|
+
calories: "Calories",
|
|
351
|
+
fat: "Fat",
|
|
352
|
+
sat_fat: "saturates",
|
|
353
|
+
mono_fat: "mono-unsaturates",
|
|
354
|
+
poly_fat: "poly-unsaturates",
|
|
355
|
+
carbs: "Carbohydrates",
|
|
356
|
+
sugar: "sugars",
|
|
357
|
+
fiber: "Fiber",
|
|
358
|
+
protein: "Protein",
|
|
359
|
+
sodium: "Sodium",
|
|
360
|
+
alcohol: "Alcohol"
|
|
361
|
+
}
|
|
320
362
|
},
|
|
321
363
|
playground: {
|
|
322
364
|
title: "Gram Playground",
|
|
@@ -374,17 +416,44 @@ var en3 = {
|
|
|
374
416
|
massStandardization: "Mass Standardization",
|
|
375
417
|
massDesc: "Converts all ingredient quantities into grams.",
|
|
376
418
|
yieldManagement: "Yield Management",
|
|
377
|
-
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."
|
|
378
422
|
},
|
|
379
423
|
output: {
|
|
380
424
|
copy: "Copy to clipboard",
|
|
381
425
|
loading: "Loading viewer..."
|
|
382
426
|
},
|
|
383
427
|
warnings: {
|
|
428
|
+
consoleTitle: "Diagnostics & Debug",
|
|
429
|
+
errors: "Errors",
|
|
430
|
+
error: "Error",
|
|
384
431
|
warnings: "Warnings",
|
|
385
432
|
warning: "Warning",
|
|
433
|
+
infos: "Notices",
|
|
434
|
+
info: "Notice",
|
|
386
435
|
item: "Item",
|
|
387
|
-
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
|
+
},
|
|
454
|
+
mobileTabs: {
|
|
455
|
+
editor: "Editor",
|
|
456
|
+
preview: "Preview"
|
|
388
457
|
},
|
|
389
458
|
analysisOptions: "Analysis Options",
|
|
390
459
|
analysis: "Analysis",
|
|
@@ -444,9 +513,30 @@ var fr3 = {
|
|
|
444
513
|
purchasingWeight: "Poids d'achat (incluant d\xE9chets/\xE9pluchures)",
|
|
445
514
|
gross: "brut",
|
|
446
515
|
intermediateResult: "R\xE9sultat interm\xE9diaire pour cette section",
|
|
516
|
+
moduleFrom: "Depuis ce module",
|
|
447
517
|
estimatedSuffix: " (Estim\xE9)",
|
|
448
518
|
missingMass: " (Manquant : ",
|
|
449
|
-
someIngredients: "certains ingr\xE9dients"
|
|
519
|
+
someIngredients: "certains ingr\xE9dients",
|
|
520
|
+
nutritionWholeRecipe: "Recette enti\xE8re",
|
|
521
|
+
nutritionPerPortion: "Par portion",
|
|
522
|
+
nutritionPer100g: "Pour 100 g",
|
|
523
|
+
nutritionRawMassNote: "Sur {mass} d'ingr\xE9dients, avant cuisson",
|
|
524
|
+
nutritionRawMassNotePartial: "Sur les {mass} renseign\xE9s, avant cuisson",
|
|
525
|
+
incompleteData: "Donn\xE9es incompl\xE8tes",
|
|
526
|
+
ofWhich: "dont",
|
|
527
|
+
nutrients: {
|
|
528
|
+
calories: "Calories",
|
|
529
|
+
fat: "Mati\xE8res grasses",
|
|
530
|
+
sat_fat: "acides gras satur\xE9s",
|
|
531
|
+
mono_fat: "acides gras mono-insatur\xE9s",
|
|
532
|
+
poly_fat: "acides gras polyinsatur\xE9s",
|
|
533
|
+
carbs: "Glucides",
|
|
534
|
+
sugar: "sucres",
|
|
535
|
+
fiber: "Fibres",
|
|
536
|
+
protein: "Prot\xE9ines",
|
|
537
|
+
sodium: "Sodium",
|
|
538
|
+
alcohol: "Alcool"
|
|
539
|
+
}
|
|
450
540
|
},
|
|
451
541
|
playground: {
|
|
452
542
|
title: "Playground Gram",
|
|
@@ -504,17 +594,44 @@ var fr3 = {
|
|
|
504
594
|
massStandardization: "Standardisation des masses",
|
|
505
595
|
massDesc: "Convertit toutes les quantit\xE9s d'ingr\xE9dients en grammes.",
|
|
506
596
|
yieldManagement: "Gestion du rendement",
|
|
507
|
-
nutrition: "Estimation nutritionnelle"
|
|
597
|
+
nutrition: "Estimation nutritionnelle",
|
|
598
|
+
stockTitle: "En stock (masquer les \xE9tapes)",
|
|
599
|
+
stockDesc: "Consid\xE9r\xE9 comme d\xE9j\xE0 disponible \u2014 se r\xE9duit \xE0 une ligne d'achat, sans \xE9tapes sur la frise."
|
|
508
600
|
},
|
|
509
601
|
output: {
|
|
510
602
|
copy: "Copier dans le presse-papier",
|
|
511
603
|
loading: "Chargement du lecteur..."
|
|
512
604
|
},
|
|
513
605
|
warnings: {
|
|
606
|
+
consoleTitle: "Diagnostics & D\xE9bogage",
|
|
607
|
+
errors: "Erreurs",
|
|
608
|
+
error: "Erreur",
|
|
514
609
|
warnings: "Avertissements",
|
|
515
610
|
warning: "Avertissement",
|
|
611
|
+
infos: "Informations",
|
|
612
|
+
info: "Information",
|
|
516
613
|
item: "\xC9l\xE9ment",
|
|
517
|
-
show: "Afficher"
|
|
614
|
+
show: "Afficher",
|
|
615
|
+
expandConsole: "D\xE9velopper la console",
|
|
616
|
+
collapseConsole: "R\xE9duire la console"
|
|
617
|
+
},
|
|
618
|
+
errorState: {
|
|
619
|
+
title: "G\xE9n\xE9ration interrompue",
|
|
620
|
+
blockingDescription: "La recette contient des erreurs bloquantes emp\xEAchant la g\xE9n\xE9ration de l'aper\xE7u.",
|
|
621
|
+
jumpToError: "Aller \xE0 l'erreur",
|
|
622
|
+
line: "Ligne"
|
|
623
|
+
},
|
|
624
|
+
tabs: {
|
|
625
|
+
addFile: "Ajouter un fichier",
|
|
626
|
+
removeFile: "Supprimer le fichier",
|
|
627
|
+
renameFile: "Renommer le fichier",
|
|
628
|
+
entryFile: "Entr\xE9e",
|
|
629
|
+
newFileName: "Nom du nouveau fichier",
|
|
630
|
+
previewingStandalone: "Aper\xE7u isol\xE9 de"
|
|
631
|
+
},
|
|
632
|
+
mobileTabs: {
|
|
633
|
+
editor: "\xC9diteur",
|
|
634
|
+
preview: "Aper\xE7u"
|
|
518
635
|
},
|
|
519
636
|
analysisOptions: "Options d'Analyse",
|
|
520
637
|
analysis: "Analyse",
|
|
@@ -553,6 +670,7 @@ export {
|
|
|
553
670
|
getDefaultCategories,
|
|
554
671
|
getDictionary,
|
|
555
672
|
isCategoryKey,
|
|
673
|
+
isCoarseUnit,
|
|
556
674
|
normalizeUnit,
|
|
557
675
|
resolveTimeUnit
|
|
558
676
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gram-lang/i18n",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
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"
|