# @gram-lang/i18n ## 1.5.2 ### Patch Changes - ccdbca7: **Kitchen & i18n**: Timers with decimal fractions (`~{1.5/2 min}`, `~{1,5/2 h}`) now work instead of raising `INVALID_DURATION`. ## 1.5.1 ### Patch Changes - 9af07c9: **Renderer, CLI & i18n**: Displayed quantities now round by significant digits rather than a fixed decimal per unit, fixing inaccurate or zeroed amounts introduced in 1.4.0: - Amounts keep three significant digits (two below 1) without truncating whole numbers (`0.15 kg` stays `0.15 kg`, `0.02 kg` no longer reads `0`), while kitchen fractions stay unchanged. - Weights in grams keep one decimal from `1 g` upwards and no longer render as `0 g` below `0.05 g`. - Adds `formatAmount`, `roundAmount`, and `amountDecimals` in `@gram-lang/i18n`. - 3080adf: **Kitchen, Analyzer & i18n**: Small quantities are no longer stored as zero across scaled amounts, shopping totals, resolved ratios, and standardized weights: - Stored values keep two decimals as before, but never fewer than two significant digits (`0.02 kg` divided by 10 stays `0.002 kg`, and a ratio weighing `0.0047 g` keeps its weight). - Adds `roundQuantity` in `@gram-lang/i18n` (re-exported by `@gram-lang/kitchen`). ## 1.5.0 ### Minor Changes - 073d4f1: **Parser & Kitchen**: An ingredient or intermediate quantity can now be written as a sum or difference of terms (`@flour{1 cup + 1 tbsp}`, `@sugar{1 cup - 2 tbsp}`, `@butter{1 cup + 20 g}`, `&dough{1 kg + 200 g}`): - Supports any number of `+`/`-` terms (including fractions and ranges) on ingredients, composite parents (`<@oranges{1 lb + 4 oz}`), and intermediates (including `@use` base yields); scaling multiplies each term, and `gram import` now preserves multi-measure sums instead of folding them into decimals. - Steps and section ingredient lists keep sums as written (`100 g + 100 g`), while scaled amounts format cleanly for cooking (`2 cup + 2 tbsp`, `2.4 kg`); compiled JSON stores terms in `parts` (with `minus: true` for subtraction) and totals in `qty`/`unit` (or full text in `unit` for mixed unit kinds). - Invalid sums (missing unit, percentage, multiplication, subtracting a range or across unit kinds, zero total) raise `INVALID_QUANTITY` with a suggestion in `data`; `OZ_AFTER_VOLUME` flags `oz` after a volume (`{1 cup + 2 oz}`), and `INVALID_UNIT` suggests a sum for adjacent quantities (`{1 kg 200 g}`). - Masses and nutrition weigh each term individually (returning no mass if any term cannot be weighed), `gram diff` shows formatted quantities via `fromText`/`toText`, `@gram-lang/renderer` exports `formatUsageQuantity`, and `@gram-lang/i18n` exports `termsTotal`, `mergeTerms`, `formatTerms`, and `Term`. - e0f8fbf: **Parser & Kitchen**: Decimal numbers can now be written with a comma as well as a point (`{1,5 kg}` and `{1.5 kg}`): - Supported in all braced numbers (ingredients, ranges, relative quantities, cookware, temperatures, timers, and section anchors) and displayed in the reader's locale. - Commas followed by exactly three digits (`{1,000 g}`) are still read as decimals (`1 g`), with a new `AMBIGUOUS_NUMBER` warning in case a thousand was intended (while `{1.000 kg}` remains `1 kg` without warning). - `gram format` trims trailing zeros after a comma (`{1,50}` → `{1,5}`) while keeping `{1,000}` as written. - 8d1b62e: **Parser & Kitchen**: Timers and section anchors now support natural duration syntax in English and French, with or without spaces: - Accepts compound durations (`~{1h30}`, `~{1 hr 30 mins}`, `~{1 heure 30}`, `~{1h + 30min}`, `~{2min30}`), clock notation (`~{1:30 h}`, `~{0:04:30}`), primes (`~{5'30"}`, `~{10'}`), ranges (`~{1h30-2h}`, `~{45 min - 1 h}`), section anchors (`~{-1h30}`, `~{-1j 12h}`), and aliases like `hr`, `hrs`, and `mn`. `gram import` now outputs these natural forms and avoids ambiguous notations like `~{1:30}`. - Ambiguous or invalid durations (`~{1:30}`, `~{1h75}`, reversed ranges) raise `INVALID_DURATION` with a suggested fix and are excluded from total time; anchor warnings now point directly to the anchor. - Compiled timers store the source text in `raw` and total minutes in `minutes` (normalizing `quantity`/`unit` to the smallest written unit for new forms) and are scheduled like any other timer. - Exposes `parseDuration` (`@gram-lang/i18n`) and `readAnchor` (`@gram-lang/kitchen`), and adds `loc` to AST section anchors. - 0fa8c95: **Rendering**: Timers in steps now format durations consistently with the rest of the page using non-breaking spaces (`~{90min}` and `~{1h30}` display as `1 h 30 min`, ranges as `45 min – 1 h` or `1–2 h`), across views, `gram cook`, and the run sheet, via the new `formatDurationRange` and `formatTimerDuration` helpers and the `formatDuration` option. **Deprecated** - `@gram-lang/i18n`: `runSheetRange` in the renderer dictionary (`"{min} to {max}"`), no longer used by the run sheet, will be removed in 2.0.0. Use `formatDurationRange()` from `@gram-lang/renderer` instead. - d5fe9c3: **Parser, Kitchen & Analyzer**: Ingredients, intermediates, and timers can now be written as unit ratios: - Supports ratios across units or counts on ingredients (`@eggs{1 / 100 g @&flour}`, `@salt{15 g / 1 L @&water}`), homemade preparations (`&stock{250 ml / 100 g @&rice}`, plus percentages like `&stock{250% @&rice}`), and proportional timers (`~{15 min / 500 g @&roast}`, `~{4 min / @&cutlet}`). - Resolves compatible units at compile time and cross-family ratios via the ingredient database; incompatible or zero-denominator ratios raise `RELATIVE_QUANTITY_UNKNOWN_MASS` (with `reason`) or `INVALID_QUANTITY` (`reason: "zeroRatioDenominator"`) instead of guessing. - Whole-use references to a section preparation (`Roll out the &dough`) now estimate mass from the producing section, while step-produced intermediates (`Mix … ->&dough`) require an explicit amount (`reason: "stepProducer"`); warnings and formulas in imported bases display original author names rather than internal aliases. - Scaling a recipe re-resolves all ratios and recomputes the schedule, total times, and shopping list. - Views display resolved ratios in tooltips, and the language server provides syntax highlighting, target completion, intermediate renaming, hover previews, and inlay hints. ## 1.4.2 No changes in this release. ## 1.4.1 ### Patch Changes - 7fbd5c6: **Renderer & CLI**: Totals where you buy or read an overview (shopping list, recipe/section weight, nutrition base, `gram shop`) convert metric amounts from 1000 g/ml up to `kg` or `l` (`3.9 kg` instead of `3900 g`), while steps, section ingredients, the run sheet, and `gram cook` keep grams for weighing (API helpers: `toLargerMetricUnit`, `isMetricMassUnit` in `@gram-lang/i18n`). - 2327de6: **Renderer & CLI**: Numbers follow the recipe's language (`lang` / project `language`, with decimal commas in French and no thousands separators in `gram shop`/`gram scale`), and spoons, cups, and imperial measures display as fractions (`1 3/4 cup`) across views and CLI commands while keeping machine attributes unchanged (API helpers: `formatNumber`, `localizeDecimals`, `toKitchenFraction` in `@gram-lang/i18n`). ## 1.4.0 ### Minor Changes - **Renderer / Durations**: Durations read more naturally, in the reader's language: - A duration of a day or more is written in days and hours (a recipe of 25 hours shows `1d 1h`, `1j 1h` in French), and minutes are written `min` (`1h 30min`), in every view; the total time tooltip ends on the exact total (`= 25h 6min`) - `formatDuration()` takes the language as an optional second argument and `{ days: false }` as a third, and a new `durationUnits` entry of `@gram-lang/i18n` holds the units of each language - **I18n**: A new `fillTemplate(template, values)` fills the `{name}` placeholders of a dictionary string (`"Serve at {time}"` becomes `"Serve at 20:00"`), leaving a name with no value as written. ## 1.3.0 ### Minor Changes - fac320b: **Parser & Kitchen**: Units written with abbreviation dots are now understood: - `{1/2 c.à.s}`, `{1 c. à c.}`, `{2 fl. oz.}` and similar spellings now parse and are recognized as the same unit as `càs`, `càc` or `fl oz` **Fixed** - **Parser**: A quantity in braces that can't be read (for example `@salt{1 g/l}` or a missing `}`) is now reported as an error pointing at the brace, instead of being ignored and merging the ingredient with others that share the same first word ## 1.2.1 ### Patch Changes - c8c4d49: **Documentation & Playground**: Improved accessibility and keyboard navigation across the website and interactive playground (ARIA roles, tab navigation, `prefers-reduced-motion`). ## 1.2.0 ### Minor Changes - 2bab3cd: **Parser & Kitchen**: Introduced modular recipes and multi-file imports via the `@use` directive: - Import external base recipes directly into a recipe using `@use "./bases/shortcrust-pastry.gram" as &shortcrust`. - Imported steps seamlessly interleave into the global ALAP scheduling timeline, preserving resting times and dependencies. - Automatically scales imported base quantities when referenced with specific yields (e.g. `&shortcrust{250g}` halves a 500 g base recipe). - Supports destructured multi-yield imports (e.g. `@use "./bases/tart-elements.gram" as { &crust, &frangipane }`) scaling each component independently. - Supports multi-word bindings using bracket notation (e.g. `@use "..." as &pastry dough{}`). - Resolves project-root paths (`@/bases/...`) and custom path aliases defined under `paths:` in `.gram/config.yaml`. - Added `--stock` CLI flag to treat pre-made base imports as stock items (zero timeline overhead, single shopping list line, retaining full nutritional totals). - Supports retro-planning timeline offsets directly on `@use` import lines (e.g. `@use "./bases/levain-starter.gram" as &starter ~{-2d}`). - Spliced sections in HTML, Markdown, and print outputs display origin badges crediting their source module. - `gram diff` and `gram watch` now track import additions, removals, rebinding, rescaling, and dependency file changes. - Language Server and VS Code extension support live dependency composition, Go to Definition into base files, path auto-completion, and quick-fix diagnostics for missing exports. - Exported `createMemoryHost` from `@gram-lang/modules` for browser and in-memory module graph resolution. - Corrected whole-recipe mass and nutrition totals to accurately include spliced intermediate (`-> &`) masses. - Normalized rescaled ingredient quantities to one decimal place for display consistency across all outputs. ### Patch Changes - f617b4c: **Parser & Kitchen**: Improved clarity and tone for diagnostic messages and revised severity tiers: - Reworded compiler and module diagnostic messages to provide actionable guidance and avoid alarmist phrasing for standard culinary approximations. - Reclassified non-critical notices (`MISSING_MACROS`, `UNKNOWN_MASS`, `TRACK_CONTENTION`) to `info` severity so they do not clutter warning counters. - Enhanced Playground and editor diagnostic styling with dedicated color schemes for errors (red), warnings (amber), and notices (blue). - 8a4056b: **Language Server**: Normalized error states and unified diagnostic handling across Playground and VSCode extensions: - Unified Playground diagnostics into a centralized full-width debug console with filter pills and interactive jump-to-location navigation. - Added mobile segmented tab navigation (`[Editor]` / `[Preview]`) and responsive single-row toolbar layout for mobile viewports. - Resolved nutrition diagnostics disconnection in the analyzer by merging physical and nutritional warnings into primary compiler warnings — the editor only turns these into squiggles when they carry a real position, so an incomplete-nutrition notice no longer misplaces itself at the top of the file. - Markdown and print HTML exports keep their explicit "incomplete data" note next to the affected nutrition figures; the interactive HTML preview conveys the same gap through its coverage badge instead. - A scale-target that fails to resolve (e.g. an unconvertible unit) now correctly turns the Playground's status badge and error panel red instead of being undersold as a warning, without marking the file tab as if the recipe itself had a syntax error. - The Playground diagnostics console no longer gets stuck filtered on a category that just emptied out (e.g. after fixing the warning it was showing). - Resolved silent compilation failures in the Language Server by capturing pipeline exceptions and pushing actionable error notifications to webviews — including when the thrown error carries no message, which previously slipped past the check silently. - A compile-time failure (parses fine, but `compile()`/`analyze()` throws) now also surfaces as an editor diagnostic, not only as a webview notification, so it's still visible with the preview panel closed. - Added bidirectional webview messaging in the VSCode extension to jump directly to error offsets in the active editor. - Localized the Playground diagnostics console's collapse/expand tooltip, previously hardcoded in French regardless of site locale. ## 1.1.0 ### Minor Changes - fbb7511: **Nutrition & Rendering**: Support flexible nutrition serving bases (per portion and per 100 g) alongside whole-recipe totals: - Declaring `portions:` in recipe frontmatter now calculates per-portion nutrition and keeps values constant when scaling recipes. - Added a standardized `per-100g` nutrition basis calculated from raw assembled recipe mass. - Added the `--nutrition ` option to `gram view`, `gram export`, and `gram print`. - Added nutrition basis toggles in the web playground and VS Code live preview. - Localized all nutrient names and table headers across supported languages (French and English). ## 1.0.1 ## 1.0.0 ### Major Changes - Gram v1.0.0 Official Launch! 🎉 This milestone release marks the official 1.0.0 launch of Gram: - **Brand-New Website & Documentation**: Rebuilt using Astro and Starlight with refined guides and an integrated blog. - **Refreshed Visual Identity**: Brand-new logo. - **Infrastructure & Stability**: Monorepo stability, test coverage, and migration to self-hosted Forgejo (`git.gram-lang.org`) mirrored to GitHub and Codeberg. ## 1.0.0-beta.5 ### Minor Changes - b1aa8db: `@gram-lang/i18n` now also owns the numeric conversion factors for units (grams, milliliters, etc.) and time (minutes, hours, etc.), exported as `UNIT_CONVERSIONS` and `TIME_TO_MINUTES` — previously split across `@gram-lang/analyzer` and hardcoded inside `@gram-lang/kitchen`. No behavior changes; this just puts everything about units and time in one place. - 79d835c: Food categories now have stable, language-independent keys (`CATEGORY_KEYS`, `CategoryKey`, `getCategoryLabels`, `isCategoryKey`) instead of only translated display labels. This means `gram db enrich` now stores a category identity that stays consistent regardless of your configured language, rather than a French or English label baked in at write time. ### Patch Changes - 68a2a45: Fixed several French unit words silently resolving to the wrong physical quantity: - `quart`/`quarts` no longer resolves to the US liquid quart (946 mL) in French recipes — it's a false friend ("un quart d'heure" means "a quarter of an hour", not a unit of volume). It's now reported as an unknown unit instead of silently misinterpreted. The English word `quart`/`quarts` still works in English recipes; only the spelled-out alias was removed, `qt` still works everywhere. - `livre` now converts using the French "livre métrique" (500 g) instead of being silently treated as the imperial pound (453.592 g) — a ~10% error. - `tasse` now converts using the French cup (250 mL) instead of being silently treated as the US cup (236.588 mL) — a ~6% error. - `pinte` no longer resolves at all: the historical French pinte has no single reliable modern value, so an explicit "unknown unit" is better than a confident-looking wrong number. - `gallon`/`gallons` now resolve correctly (previously only the abbreviation `gal` worked). ## 1.0.0-beta.4 ### Minor Changes - 68365c4: Section retro-planning (e.g. `## Section ~{-2h}`) now enforces a strict signed-duration syntax instead of accepting arbitrary free text, preventing invalid timeline calculations. Added support for the `d` (day) time unit. ### Patch Changes - fc47a86: Renamed the `cookTime` metric to `idleTime` across the ecosystem to better reflect hands-off wait time. Additionally, passive timers sharing the same name are now automatically sequenced one after another on the same background track. - 55430e4: Added detailed per-contribution time breakdowns (Active, Prep, Total) to compiled recipe metrics, and surfaced them as explanatory tooltips on the time summary badges in the HTML renderer. ## 1.0.0-beta.3 ### Patch Changes - Updated deployment configuration to automate npmjs packages publication ## 1.0.0-beta.2 ### Minor Changes - a46c24f: Upgraded all monorepo dependencies to their latest versions and implemented a TypeScript 7 dual setup for faster typechecking while preserving compilation toolchain compatibility. Fixed type errors arising from Node 26 and VS Code LSP v10 updates. ### Patch Changes - f5f1efe: chore: declare `sideEffects: false` so bundlers can tree-shake unused exports from these packages No package previously declared this, so third-party bundlers had to assume every module might have side effects and couldn't safely drop unused code. ## 1.0.0-beta.1 ### Minor Changes - a244341: Major overhaul of the documentation and playground infrastructure: - **Documentation Rewrite & i18n**: The documentation has been completely rewritten, thoroughly verified, and is now fully translated into French (in addition to the English version). - **Advanced Vue 3 Playground**: The legacy playground has been removed and rebuilt from the ground up using Vue 3. This new version is directly integrated into the documentation and introduces powerful new features, including recipe scaling and baker's math. ## 1.0.0-beta.0 ### Major Changes - 2dcd766: Introduction of the official GRAM CLI (`@gram-lang/cli`), a comprehensive command-line tool to manage, compile, and interact with your recipes. **Project & Recipe Management:** - **Project Setup**: `gram init` safely scaffolds a `.gram` environment, including interactive AI provider setup (Google, OpenAI, Anthropic, Ollama) and secret management. - **Automated Import**: `gram import` scrapes recipes from any URL and uses AI to flawlessly translate and convert them into native `.gram` syntax. - **Validation & Compilation**: `gram check` instantly validates syntax and database integrity. `gram build` compiles recipes to robust JSON with full physical and nutritional enrichment. - **Smart Scaling & Diff**: `gram scale` dynamically resizes recipes (e.g., `--scale flour=300g`) with a visual before/after comparison. `gram diff` provides a semantic "git diff" for cooking, tracking changes in quantities, timings, and steps. - **Export & Print**: `gram print` generates a beautifully typeset A4 HTML recipe card. `gram export` converts recipes to clean Markdown or static HTML. - **Auto-formatting & Watcher**: `gram format` automatically enforces `.gram` language styling standards. `gram watch` provides real-time validation upon saving. **Interactive Cooking & Daily Use:** - **Terminal Cooking Assistant (`gram cook`)**: A step-by-step interactive TUI (Terminal User Interface) that guides you through the recipe, featuring a dynamic ingredient checklist and live background timers. - **Smart Shopping List (`gram shop`)**: Aggregates ingredients across multiple recipes, automatically converting volumes to masses and sorting them by supermarket aisle. - **Recipe Search (`gram suggest`)**: An alias-aware search engine to find recipes based on your available ingredients (e.g., `--with "butter, eggs" --without "milk"`). - **Rich Terminal Preview (`gram view`)**: Renders recipes directly in the terminal with color coding, active timers, and nutritional tables. **AI-Powered Database Management (`gram db`):** - **Smart Database Sync & Enrichment**: `gram db sync` automatically tracks new ingredients across your project. `gram db enrich` uses AI to automatically fill in missing densities, unit weights, categories, and nutrition facts. - **Semantic Linting & Conflict Resolution**: `gram db lint` uses AI to detect plural mistakes and semantic duplicates (e.g., `scallion` vs `green onion`). `gram db merge` handles conflicts when integrating external community databases. ### Minor Changes - 79105ce: Complete overhaul of the VS Code Extension with Language Server, Live Preview, and advanced assistance **Major New Features:** - **Full Language Server (LSP)**: The extension now ships with a complete language server. All advanced features activate instantly upon opening a `.gram` file. - **Dynamic Live Preview**: A side-by-side WebView panel displaying the real-time HTML render of the recipe as you type. - Gracefully handles syntax errors via a visual fallback. - Integrates the official Playground styles for perfect consistency. - **CodeLens & Inlay Hints**: - **Inlay Hints**: Displays the cumulative total time in gray next to section titles. - **CodeLens**: Clickable buttons `▶ Preview` and `📊 Macros` above the main recipe title for quick access. **Ingredient Database & Nutrition:** - **Automatic Loading**: Automatically detects and loads `.gram/ingredients.yaml` from the workspace root (or via the path configured in `gram.ingredientDatabase.path` settings). Optimized indexing (O(1)) for maximum performance. - **Seamless Plural Management**: The extension silently handles plurals (e.g., `@carrots{3}` will automatically match `carrot`). No error diagnostics are raised, everything is transparent. - **Nutritional Hover & Macros Panel**: - Hovering over an ingredient displays a complete nutritional table (calories, proteins, carbs, fats, etc.). - The Live Preview integrates a Macros panel (hidden by default) that can be shown via CodeLens, featuring clear visual alerts for ingredients missing data. - **Fuzzy Matching "Did you mean?"**: Levenshtein algorithm (distance ≤ 2) suggests corrections if an ingredient is misspelled (e.g., `@tomaato` suggests `@tomato`). Directly integrated into Quick Fix code actions. - **On-Hover Unit Conversion**: Automatically converts volumes (ml, tbsp, etc.) to grams when hovering over an ingredient if its density is known in the database. **Editing Assistance & Navigation:** - **Advanced Contextual Autocompletion**: - After `@`: Suggests ingredients and their aliases from the YAML database. Automatically adds curly braces `{}` for multi-word names. - After `&`: Suggests only the existing intermediate declarations in the document. - Inside `{}`: Suggests canonical units (mass, volume, time) and their aliases (French/English) as soon as a digit is typed. - **Smart Navigation**: - **Go to Definition** (`Ctrl+Click` / `F12`) on a `&ref` reference to jump to its `->&ref` declaration. - **Find All References** (`Shift+F12`) to list all usages of an intermediate. - **Rename Symbol** (`F2`) to atomically rename an intermediate (declaration + references). - **Outline Panel** showing the hierarchy of sections and elements, with foldable code in the gutter. - **Intermediate Hover**: Displays the full text of the step where the intermediate was created. **Diagnostics & Code Actions (Quick Fixes):** - **Real-Time Diagnostics**: - Red underline for an orphaned `&ref` reference. - Warning for an unused `->&ref` declaration. - Warning if the frontmatter (title) is missing. - **Code Actions (💡)**: - _Quick Fix_: Insert the missing `title:` in the frontmatter. - _Quick Fix_: Remove an unused intermediate declaration. - _Quick Fix_: Declare a missing intermediate for an existing reference. - _Refactor_: Convert a volume quantity to mass directly in the code. - _Refactor_: Replace a misspelled ingredient with the closest Fuzzy match suggestion. **Semantic Highlighting, Formatting & Snippets:** - **Semantic Tokens**: Regex-based syntax highlighting (TextMate) is replaced by **AST-driven** highlighting. Offers surgical precision for ingredients, timers, temperatures, comments, and nested units (e.g., precise separation of value and unit in `{10g}`). - **Auto-formatting (`Alt+Shift+F`)**: - Normalization of spaces inside curly braces (`{ 200 g }` → `{200g}`). - Normalization of composite ingredients (`@a < @b` → `@a<@b`). - Alignment of section titles and tab-to-space conversions. - **Built-in Snippets**: Keyboard shortcuts for the basic structure (frontmatter, sections, steps), ingredient variants (`@ing`, `@?`, `@-`), cookware (`#cw`), and timers/temperatures. - caf1630: Major architecture refactoring, ESM Migration, performance optimizations and code cleanup ## 0.10.1 ### Patch Changes - Cleaned up and updated dependencies. - Implemented Turborepo to optimize and simplify project building. ## 0.10.0 ### Minor Changes - cfda9e1: Refactored unit translation and normalization into a new centralized @gram-lang/i18n package to remove redundancy between the compiler and analyzer. ### Patch Changes - 3720644: Added Zod to automatically catch invalid data and prevent crashes.