@gram-lang/i18n 1.0.0-beta.2
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/README.md +64 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.js +408 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @gram-lang/i18n
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@gram-lang/i18n)
|
|
4
|
+
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
5
|
+
|
|
6
|
+
*Part of the [Gram monorepo](https://codeberg.org/abiwab/gram).*
|
|
7
|
+
|
|
8
|
+
The translation and normalization module for units and time within the Gram recipe language. It provides high-performance, O(1) lookup dictionaries and normalizers to translate locale-specific aliases (e.g., `càs`, `cuillère à soupe`, `teaspoon`) into standardized canonical representation units (e.g., `tbsp`, `tsp`).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 📚 General Documentation
|
|
13
|
+
|
|
14
|
+
For full syntax specifications, grammar details, cheatsheets, and best practices, please refer to the **[Gram Documentation](https://gram-lang.org/)**.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🛠️ Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @gram-lang/i18n
|
|
22
|
+
# or
|
|
23
|
+
bun add @gram-lang/i18n
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ⚡ Usage
|
|
29
|
+
|
|
30
|
+
The package exports two primary normalization functions: `normalizeUnit` (for volumes/masses) and `resolveTimeUnit` (for duration units).
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { normalizeUnit, resolveTimeUnit } from '@gram-lang/i18n';
|
|
34
|
+
|
|
35
|
+
// 1. Normalizing measurement units
|
|
36
|
+
console.log(normalizeUnit('càs', 'fr')); // 'tbsp' (French alias)
|
|
37
|
+
console.log(normalizeUnit('tablespoon', 'en')); // 'tbsp' (English alias)
|
|
38
|
+
console.log(normalizeUnit('g')); // 'g' (Fallback / Global)
|
|
39
|
+
|
|
40
|
+
// 2. Normalizing time units
|
|
41
|
+
console.log(resolveTimeUnit('heures', 'fr')); // 'h'
|
|
42
|
+
console.log(resolveTimeUnit('minutes')); // 'm'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### ⚙️ How it Works
|
|
46
|
+
|
|
47
|
+
To maintain maximum performance under load (e.g., when compiling/analyzing large numbers of recipes), the dictionaries are compiled once at initialization into flat hash maps using `compileDictionary`. Lookups are `O(1)` operations.
|
|
48
|
+
|
|
49
|
+
If a language-specific code (e.g., `'fr'`) is provided, the function checks the locale dictionary first. If it cannot find the alias, or if no language is specified, it falls back to a global, unified dictionary mapping.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🏗️ Structure
|
|
54
|
+
|
|
55
|
+
* `src/index.ts`: The main package entry point.
|
|
56
|
+
* `src/dictionary.ts`: Dictionary compiler helper that transforms structured translations into flat `O(1)` maps.
|
|
57
|
+
* `src/units.ts`: Mass and volume unit dictionary (French & English) and normalizer.
|
|
58
|
+
* `src/time.ts`: Time unit dictionary (French & English) and normalizer.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 📄 License
|
|
63
|
+
|
|
64
|
+
This project is licensed under the GPL-3.0 License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
type LanguageDict = Record<string, string[]>;
|
|
2
|
+
type CompiledDict = Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Compiles human-readable language dictionaries into optimized O(1) lookup tables.
|
|
5
|
+
* Generates both language-specific lookups and a unified global fallback lookup.
|
|
6
|
+
*/
|
|
7
|
+
declare function compileDictionary(dictionaries: Record<string, LanguageDict>): {
|
|
8
|
+
byLang: Record<string, CompiledDict>;
|
|
9
|
+
global: CompiledDict;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare const TIME_DICTIONARIES: {
|
|
13
|
+
en: LanguageDict;
|
|
14
|
+
fr: LanguageDict;
|
|
15
|
+
};
|
|
16
|
+
declare const TIME_BY_LANG: Record<string, CompiledDict>;
|
|
17
|
+
declare const TIME_GLOBAL: CompiledDict;
|
|
18
|
+
/**
|
|
19
|
+
* Helper to normalize a time unit string into its canonical alias ('h', 'm', 's').
|
|
20
|
+
*/
|
|
21
|
+
declare const resolveTimeUnit: (unit?: string | null, lang?: string) => string;
|
|
22
|
+
|
|
23
|
+
declare const UNIT_DICTIONARIES: {
|
|
24
|
+
en: LanguageDict;
|
|
25
|
+
fr: LanguageDict;
|
|
26
|
+
};
|
|
27
|
+
declare const UNIT_BY_LANG: Record<string, CompiledDict>;
|
|
28
|
+
declare const UNIT_GLOBAL: CompiledDict;
|
|
29
|
+
/**
|
|
30
|
+
* Normalizes a raw string unit into a standard canon unit.
|
|
31
|
+
* Examples: 'càs' -> 'tbsp', 'kilo' -> 'kg'.
|
|
32
|
+
*/
|
|
33
|
+
declare function normalizeUnit(rawUnit: string | undefined | null, lang?: string): string;
|
|
34
|
+
|
|
35
|
+
declare function getAiLanguageInstruction(lang?: string): string;
|
|
36
|
+
|
|
37
|
+
declare function getDefaultCategories(lang?: string): string[];
|
|
38
|
+
|
|
39
|
+
declare const en: {
|
|
40
|
+
renderer: {
|
|
41
|
+
shoppingList: string;
|
|
42
|
+
cookware: string;
|
|
43
|
+
equipment: string;
|
|
44
|
+
nutrition: string;
|
|
45
|
+
totalTime: string;
|
|
46
|
+
cookTime: string;
|
|
47
|
+
activeTime: string;
|
|
48
|
+
prepTime: string;
|
|
49
|
+
est: string;
|
|
50
|
+
passiveTimeTooltip: string;
|
|
51
|
+
activeTimeTooltip: string;
|
|
52
|
+
estimateTooltip: string;
|
|
53
|
+
coverageTooltip: string;
|
|
54
|
+
unknownCookware: string;
|
|
55
|
+
reset: string;
|
|
56
|
+
originalRecipe: string;
|
|
57
|
+
sectionStandardizedMass: string;
|
|
58
|
+
bakersPercentage: string;
|
|
59
|
+
standardized: string;
|
|
60
|
+
optional: string;
|
|
61
|
+
calculationPartialOrFailed: string;
|
|
62
|
+
standardizedMass: string;
|
|
63
|
+
quantity: string;
|
|
64
|
+
intermediateIngredient: string;
|
|
65
|
+
alternatives: string;
|
|
66
|
+
decreasePortions: string;
|
|
67
|
+
editPortions: string;
|
|
68
|
+
increasePortions: string;
|
|
69
|
+
returnToStep: string;
|
|
70
|
+
mixedUnitsTooltip: string;
|
|
71
|
+
mixedUnits: string;
|
|
72
|
+
purchasingWeight: string;
|
|
73
|
+
gross: string;
|
|
74
|
+
intermediateResult: string;
|
|
75
|
+
estimatedSuffix: string;
|
|
76
|
+
missingMass: string;
|
|
77
|
+
someIngredients: string;
|
|
78
|
+
};
|
|
79
|
+
playground: {
|
|
80
|
+
title: string;
|
|
81
|
+
inputTab: string;
|
|
82
|
+
writePlaceholder: string;
|
|
83
|
+
outputTab: string;
|
|
84
|
+
viewLabel: string;
|
|
85
|
+
loadExample: string;
|
|
86
|
+
recipe: string;
|
|
87
|
+
scaleFactor: string;
|
|
88
|
+
examples: {
|
|
89
|
+
canneles: string;
|
|
90
|
+
empanadas: string;
|
|
91
|
+
};
|
|
92
|
+
views: {
|
|
93
|
+
json: string;
|
|
94
|
+
ast: string;
|
|
95
|
+
jsonTree: string;
|
|
96
|
+
markdown: string;
|
|
97
|
+
preview: string;
|
|
98
|
+
};
|
|
99
|
+
options: {
|
|
100
|
+
scaleTitle: string;
|
|
101
|
+
selectIngredient: string;
|
|
102
|
+
qty: string;
|
|
103
|
+
unit: string;
|
|
104
|
+
apply: string;
|
|
105
|
+
bakersMath: string;
|
|
106
|
+
enableBakersMath: string;
|
|
107
|
+
bakersMathDesc: string;
|
|
108
|
+
hideAbsolute: string;
|
|
109
|
+
forceReference: string;
|
|
110
|
+
autoDetect: string;
|
|
111
|
+
physicalAnalysis: string;
|
|
112
|
+
massStandardization: string;
|
|
113
|
+
massDesc: string;
|
|
114
|
+
yieldManagement: string;
|
|
115
|
+
nutrition: string;
|
|
116
|
+
};
|
|
117
|
+
output: {
|
|
118
|
+
copy: string;
|
|
119
|
+
loading: string;
|
|
120
|
+
};
|
|
121
|
+
warnings: {
|
|
122
|
+
warnings: string;
|
|
123
|
+
warning: string;
|
|
124
|
+
item: string;
|
|
125
|
+
show: string;
|
|
126
|
+
};
|
|
127
|
+
analysisOptions: string;
|
|
128
|
+
analysis: string;
|
|
129
|
+
massNorm: string;
|
|
130
|
+
yieldMgmt: string;
|
|
131
|
+
nutritionEst: string;
|
|
132
|
+
statusValid: string;
|
|
133
|
+
statusWarnings: string;
|
|
134
|
+
copyBtn: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
type GramLocale = typeof en;
|
|
138
|
+
|
|
139
|
+
declare function getDictionary(lang?: string): GramLocale;
|
|
140
|
+
|
|
141
|
+
export { type CompiledDict, type GramLocale, type LanguageDict, TIME_BY_LANG, TIME_DICTIONARIES, TIME_GLOBAL, UNIT_BY_LANG, UNIT_DICTIONARIES, UNIT_GLOBAL, compileDictionary, getAiLanguageInstruction, getDefaultCategories, getDictionary, normalizeUnit, resolveTimeUnit };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
// src/dictionary.ts
|
|
2
|
+
function compileDictionary(dictionaries2) {
|
|
3
|
+
const byLang = {};
|
|
4
|
+
const global = {};
|
|
5
|
+
for (const [lang, dict] of Object.entries(dictionaries2)) {
|
|
6
|
+
const compiledLang = {};
|
|
7
|
+
for (const [canonical, aliases] of Object.entries(dict)) {
|
|
8
|
+
compiledLang[canonical] = canonical;
|
|
9
|
+
global[canonical] = canonical;
|
|
10
|
+
for (const alias of aliases) {
|
|
11
|
+
const lowerAlias = alias.toLowerCase();
|
|
12
|
+
compiledLang[lowerAlias] = canonical;
|
|
13
|
+
global[lowerAlias] = canonical;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
byLang[lang] = compiledLang;
|
|
17
|
+
}
|
|
18
|
+
return { byLang, global };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/time.ts
|
|
22
|
+
var en = {
|
|
23
|
+
h: ["hour", "hours"],
|
|
24
|
+
m: ["min", "mins", "minute", "minutes"],
|
|
25
|
+
s: ["sec", "secs", "second", "seconds"]
|
|
26
|
+
};
|
|
27
|
+
var fr = {
|
|
28
|
+
h: ["heure", "heures"],
|
|
29
|
+
m: ["min", "mins", "minute", "minutes"],
|
|
30
|
+
s: ["sec", "secs", "seconde", "secondes"]
|
|
31
|
+
};
|
|
32
|
+
var TIME_DICTIONARIES = { en, fr };
|
|
33
|
+
var { byLang: TIME_BY_LANG, global: TIME_GLOBAL } = compileDictionary(TIME_DICTIONARIES);
|
|
34
|
+
var resolveTimeUnit = (unit, lang) => {
|
|
35
|
+
if (!unit) return "";
|
|
36
|
+
const clean = unit.trim().toLowerCase();
|
|
37
|
+
if (lang && TIME_BY_LANG[lang]?.[clean]) {
|
|
38
|
+
return TIME_BY_LANG[lang][clean];
|
|
39
|
+
}
|
|
40
|
+
return TIME_GLOBAL[clean] || clean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/units.ts
|
|
44
|
+
var en2 = {
|
|
45
|
+
// Volume — spoons
|
|
46
|
+
tsp: ["teaspoon", "teaspoons"],
|
|
47
|
+
tbsp: ["tablespoon", "tablespoons"],
|
|
48
|
+
// Volume — small measures (sub-tsp)
|
|
49
|
+
tad: ["tads"],
|
|
50
|
+
dash: ["dashes"],
|
|
51
|
+
pinch: ["pinches"],
|
|
52
|
+
smidgen: ["smidgen", "smidge", "smidgens"],
|
|
53
|
+
drop: ["drops"],
|
|
54
|
+
// Volume — cups & imperial
|
|
55
|
+
cup: ["cups"],
|
|
56
|
+
pt: ["pint", "pints"],
|
|
57
|
+
qt: ["quart", "quarts"],
|
|
58
|
+
"fl oz": ["floz", "fl. oz.", "fluid ounce", "fluid ounces"],
|
|
59
|
+
// Volume — metric
|
|
60
|
+
ml: ["milliliter", "milliliters"],
|
|
61
|
+
cl: ["centiliter", "centiliters"],
|
|
62
|
+
dl: ["deciliter", "deciliters"],
|
|
63
|
+
l: ["liter", "liters"],
|
|
64
|
+
// Weight — metric
|
|
65
|
+
mg: ["milligram", "milligrams"],
|
|
66
|
+
g: ["gram", "grams"],
|
|
67
|
+
kg: ["kilo", "kilos", "kilogram", "kilograms"],
|
|
68
|
+
// Weight — imperial
|
|
69
|
+
oz: ["ounce", "ounces"],
|
|
70
|
+
lb: ["lbs", "pound", "pounds"]
|
|
71
|
+
};
|
|
72
|
+
var fr2 = {
|
|
73
|
+
// Volume — cuillères
|
|
74
|
+
tsp: [
|
|
75
|
+
"c\xE0c",
|
|
76
|
+
"cac",
|
|
77
|
+
"c.\xE0.c",
|
|
78
|
+
"cuill\xE8re \xE0 caf\xE9",
|
|
79
|
+
"cuill\xE8res \xE0 caf\xE9",
|
|
80
|
+
"cuillere a cafe",
|
|
81
|
+
"cuilleres a cafe"
|
|
82
|
+
],
|
|
83
|
+
tbsp: [
|
|
84
|
+
"c\xE0s",
|
|
85
|
+
"cas",
|
|
86
|
+
"c.\xE0.s",
|
|
87
|
+
"cuill\xE8re \xE0 soupe",
|
|
88
|
+
"cuill\xE8res \xE0 soupe",
|
|
89
|
+
"cuillere a soupe",
|
|
90
|
+
"cuilleres a soupe"
|
|
91
|
+
],
|
|
92
|
+
// Volume — petites mesures (sous-càc)
|
|
93
|
+
tad: ["soup\xE7on", "soupcons"],
|
|
94
|
+
dash: ["trait"],
|
|
95
|
+
pinch: ["pinc\xE9e", "pincee", "pinc\xE9es", "pincees"],
|
|
96
|
+
smidgen: ["poussi\xE8re", "poussiere", "poussi\xE8res", "poussieres"],
|
|
97
|
+
drop: ["goutte", "gouttes"],
|
|
98
|
+
// Volume — tasse & mesures anglo-saxonnes
|
|
99
|
+
cup: ["tasse", "tasses"],
|
|
100
|
+
pt: ["pinte", "pintes"],
|
|
101
|
+
qt: ["quart", "quarts"],
|
|
102
|
+
"fl oz": ["once liquide", "onces liquides"],
|
|
103
|
+
// Volume — métrique
|
|
104
|
+
ml: ["millilitre", "millilitres"],
|
|
105
|
+
cl: ["centilitre", "centilitres"],
|
|
106
|
+
dl: ["d\xE9cilitre", "d\xE9cilitres", "decilitre", "decilitres"],
|
|
107
|
+
l: ["litre", "litres"],
|
|
108
|
+
// Poids — métrique
|
|
109
|
+
mg: ["milligramme", "milligrammes"],
|
|
110
|
+
g: ["gramme", "grammes"],
|
|
111
|
+
kg: ["kilo", "kilos", "kilogramme", "kilogrammes"],
|
|
112
|
+
// Poids — impérial
|
|
113
|
+
oz: ["once", "onces"],
|
|
114
|
+
lb: ["livre", "livres"]
|
|
115
|
+
};
|
|
116
|
+
var UNIT_DICTIONARIES = { en: en2, fr: fr2 };
|
|
117
|
+
var { byLang: UNIT_BY_LANG, global: UNIT_GLOBAL } = compileDictionary(UNIT_DICTIONARIES);
|
|
118
|
+
function normalizeUnit(rawUnit, lang) {
|
|
119
|
+
if (!rawUnit) return "";
|
|
120
|
+
const clean = rawUnit.toLowerCase().trim();
|
|
121
|
+
if (lang && UNIT_BY_LANG[lang]?.[clean]) {
|
|
122
|
+
return UNIT_BY_LANG[lang][clean];
|
|
123
|
+
}
|
|
124
|
+
return UNIT_GLOBAL[clean] || clean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/ai.ts
|
|
128
|
+
var LANGUAGE_NAMES = {
|
|
129
|
+
fr: "French",
|
|
130
|
+
en: "English",
|
|
131
|
+
de: "German",
|
|
132
|
+
es: "Spanish",
|
|
133
|
+
it: "Italian",
|
|
134
|
+
pt: "Portuguese",
|
|
135
|
+
nl: "Dutch",
|
|
136
|
+
ja: "Japanese",
|
|
137
|
+
zh: "Chinese"
|
|
138
|
+
};
|
|
139
|
+
function getAiLanguageInstruction(lang = "en") {
|
|
140
|
+
const name = LANGUAGE_NAMES[lang] ?? lang;
|
|
141
|
+
return `Respond exclusively in ${name}. All generated text \u2014 including category names, tags, ingredient names, and recipe content \u2014 must be in ${name}.`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/categories.ts
|
|
145
|
+
var CATEGORIES = {
|
|
146
|
+
fr: [
|
|
147
|
+
"L\xE9gumes",
|
|
148
|
+
"Fruits",
|
|
149
|
+
"Viandes",
|
|
150
|
+
"Poissons & Fruits de mer",
|
|
151
|
+
"Cr\xE9merie",
|
|
152
|
+
"C\xE9r\xE9ales",
|
|
153
|
+
"L\xE9gumineuses",
|
|
154
|
+
"Noix & Graines",
|
|
155
|
+
"Huiles",
|
|
156
|
+
"Herbes",
|
|
157
|
+
"\xC9pices",
|
|
158
|
+
"Condiments",
|
|
159
|
+
"Sucres",
|
|
160
|
+
"Boissons",
|
|
161
|
+
"Autres"
|
|
162
|
+
],
|
|
163
|
+
en: [
|
|
164
|
+
"Vegetables",
|
|
165
|
+
"Fruits",
|
|
166
|
+
"Meat",
|
|
167
|
+
"Seafood",
|
|
168
|
+
"Dairy",
|
|
169
|
+
"Grains",
|
|
170
|
+
"Legumes",
|
|
171
|
+
"Nuts",
|
|
172
|
+
"Oils",
|
|
173
|
+
"Herbs",
|
|
174
|
+
"Spices",
|
|
175
|
+
"Condiments",
|
|
176
|
+
"Sugars",
|
|
177
|
+
"Beverages",
|
|
178
|
+
"Other"
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
function getDefaultCategories(lang = "en") {
|
|
182
|
+
return CATEGORIES[lang] ?? CATEGORIES.en;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/locales/en.ts
|
|
186
|
+
var en3 = {
|
|
187
|
+
renderer: {
|
|
188
|
+
shoppingList: "Shopping List",
|
|
189
|
+
cookware: "Cookware",
|
|
190
|
+
equipment: "Equipment",
|
|
191
|
+
nutrition: "Nutrition",
|
|
192
|
+
totalTime: "Total Time",
|
|
193
|
+
cookTime: "Cook Time",
|
|
194
|
+
activeTime: "Active Time",
|
|
195
|
+
prepTime: "Prep Time",
|
|
196
|
+
est: "(est.)",
|
|
197
|
+
passiveTimeTooltip: "Passive Time (Waiting, resting...)",
|
|
198
|
+
activeTimeTooltip: "Active Time",
|
|
199
|
+
estimateTooltip: "Estimate",
|
|
200
|
+
coverageTooltip: "Coverage",
|
|
201
|
+
unknownCookware: "[Unknown Cookware]",
|
|
202
|
+
reset: "Reset",
|
|
203
|
+
originalRecipe: "Original recipe",
|
|
204
|
+
sectionStandardizedMass: "Section standardized mass",
|
|
205
|
+
bakersPercentage: "Baker's Percentage",
|
|
206
|
+
standardized: "Standardized",
|
|
207
|
+
optional: "Optional",
|
|
208
|
+
calculationPartialOrFailed: "Calculation partial or failed",
|
|
209
|
+
standardizedMass: "Standardized mass",
|
|
210
|
+
quantity: "Quantity",
|
|
211
|
+
intermediateIngredient: "Intermediate Ingredient",
|
|
212
|
+
alternatives: "Alternatives",
|
|
213
|
+
decreasePortions: "Decrease portions",
|
|
214
|
+
editPortions: "Edit portions directly",
|
|
215
|
+
increasePortions: "Increase portions",
|
|
216
|
+
returnToStep: "Return to step",
|
|
217
|
+
mixedUnitsTooltip: "Couldn't be combined into one total \u2014 add a density to the ingredient database to merge them",
|
|
218
|
+
mixedUnits: "Mixed units",
|
|
219
|
+
purchasingWeight: "Purchasing Weight (including waste/peel)",
|
|
220
|
+
gross: "gross",
|
|
221
|
+
intermediateResult: "Intermediate result for this section",
|
|
222
|
+
estimatedSuffix: " (Estimated)",
|
|
223
|
+
missingMass: " (Missing: ",
|
|
224
|
+
someIngredients: "some ingredients"
|
|
225
|
+
},
|
|
226
|
+
playground: {
|
|
227
|
+
title: "Gram Playground",
|
|
228
|
+
inputTab: "Input (.gram)",
|
|
229
|
+
writePlaceholder: "Write your recipe here...",
|
|
230
|
+
outputTab: "Output",
|
|
231
|
+
viewLabel: "View:",
|
|
232
|
+
loadExample: "Load Example...",
|
|
233
|
+
recipe: "Recipe",
|
|
234
|
+
scaleFactor: "Scale Factor %",
|
|
235
|
+
examples: {
|
|
236
|
+
canneles: "Bordeaux Cannel\xE9s",
|
|
237
|
+
empanadas: "Beef Empanadas"
|
|
238
|
+
},
|
|
239
|
+
views: {
|
|
240
|
+
json: "JSON Output",
|
|
241
|
+
ast: "AST (Raw)",
|
|
242
|
+
jsonTree: "Interactive Tree",
|
|
243
|
+
markdown: "Markdown",
|
|
244
|
+
preview: "Preview (HTML)"
|
|
245
|
+
},
|
|
246
|
+
options: {
|
|
247
|
+
scaleTitle: "Scale by Ingredient",
|
|
248
|
+
selectIngredient: "Select ingredient...",
|
|
249
|
+
qty: "Qty",
|
|
250
|
+
unit: "Unit",
|
|
251
|
+
apply: "Apply",
|
|
252
|
+
bakersMath: "Baker's Math",
|
|
253
|
+
enableBakersMath: "Enable Baker's Math",
|
|
254
|
+
bakersMathDesc: "Shows ingredients as % of reference.",
|
|
255
|
+
hideAbsolute: "Hide absolute weights",
|
|
256
|
+
forceReference: "Force Reference:",
|
|
257
|
+
autoDetect: "Auto (detect @*)",
|
|
258
|
+
physicalAnalysis: "Physical Analysis",
|
|
259
|
+
massStandardization: "Mass Standardization",
|
|
260
|
+
massDesc: "Converts all ingredient quantities into grams.",
|
|
261
|
+
yieldManagement: "Yield Management",
|
|
262
|
+
nutrition: "Nutrition Estimation"
|
|
263
|
+
},
|
|
264
|
+
output: {
|
|
265
|
+
copy: "Copy to clipboard",
|
|
266
|
+
loading: "Loading viewer..."
|
|
267
|
+
},
|
|
268
|
+
warnings: {
|
|
269
|
+
warnings: "Warnings",
|
|
270
|
+
warning: "Warning",
|
|
271
|
+
item: "Item",
|
|
272
|
+
show: "Show"
|
|
273
|
+
},
|
|
274
|
+
analysisOptions: "Analysis Options",
|
|
275
|
+
analysis: "Analysis",
|
|
276
|
+
massNorm: "Mass Normalization",
|
|
277
|
+
yieldMgmt: "Yield Management (Gross Mass)",
|
|
278
|
+
nutritionEst: "Nutrition Estimation",
|
|
279
|
+
statusValid: "Valid",
|
|
280
|
+
statusWarnings: "Warnings",
|
|
281
|
+
copyBtn: "Copy to Clipboard"
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// src/locales/fr.ts
|
|
286
|
+
var fr3 = {
|
|
287
|
+
renderer: {
|
|
288
|
+
shoppingList: "Liste de courses",
|
|
289
|
+
cookware: "Mat\xE9riel",
|
|
290
|
+
equipment: "\xC9quipement",
|
|
291
|
+
nutrition: "Nutrition",
|
|
292
|
+
totalTime: "Temps Total",
|
|
293
|
+
cookTime: "Cuisson",
|
|
294
|
+
activeTime: "Actif",
|
|
295
|
+
prepTime: "Pr\xE9paration",
|
|
296
|
+
est: "(est.)",
|
|
297
|
+
passiveTimeTooltip: "Temps passif (Repos, attente...)",
|
|
298
|
+
activeTimeTooltip: "Temps actif",
|
|
299
|
+
estimateTooltip: "Estimation",
|
|
300
|
+
coverageTooltip: "Couverture",
|
|
301
|
+
unknownCookware: "[Mat\xE9riel Inconnu]",
|
|
302
|
+
reset: "R\xE9initialiser",
|
|
303
|
+
originalRecipe: "Recette originale",
|
|
304
|
+
sectionStandardizedMass: "Masse standardis\xE9e de la section",
|
|
305
|
+
bakersPercentage: "Pourcentage du boulanger",
|
|
306
|
+
standardized: "Standardis\xE9",
|
|
307
|
+
optional: "Optionnel",
|
|
308
|
+
calculationPartialOrFailed: "Calcul partiel ou \xE9chou\xE9",
|
|
309
|
+
standardizedMass: "Masse standardis\xE9e",
|
|
310
|
+
quantity: "Quantit\xE9",
|
|
311
|
+
intermediateIngredient: "Ingr\xE9dient interm\xE9diaire",
|
|
312
|
+
alternatives: "Alternatives",
|
|
313
|
+
decreasePortions: "Diminuer les portions",
|
|
314
|
+
editPortions: "Modifier directement les portions",
|
|
315
|
+
increasePortions: "Augmenter les portions",
|
|
316
|
+
returnToStep: "Retour \xE0 l'\xE9tape",
|
|
317
|
+
mixedUnitsTooltip: "Impossible de fusionner en un seul total \u2014 ajoutez une densit\xE9 \xE0 la base de donn\xE9es pour les convertir",
|
|
318
|
+
mixedUnits: "Unit\xE9s mixtes",
|
|
319
|
+
purchasingWeight: "Poids d'achat (incluant d\xE9chets/\xE9pluchures)",
|
|
320
|
+
gross: "brut",
|
|
321
|
+
intermediateResult: "R\xE9sultat interm\xE9diaire pour cette section",
|
|
322
|
+
estimatedSuffix: " (Estim\xE9)",
|
|
323
|
+
missingMass: " (Manquant : ",
|
|
324
|
+
someIngredients: "certains ingr\xE9dients"
|
|
325
|
+
},
|
|
326
|
+
playground: {
|
|
327
|
+
title: "Playground Gram",
|
|
328
|
+
inputTab: "Entr\xE9e (.gram)",
|
|
329
|
+
writePlaceholder: "\xC9crivez votre recette ici...",
|
|
330
|
+
outputTab: "Sortie",
|
|
331
|
+
viewLabel: "Vue :",
|
|
332
|
+
loadExample: "Charger un exemple...",
|
|
333
|
+
recipe: "Recette",
|
|
334
|
+
scaleFactor: "Facteur d'\xE9chelle %",
|
|
335
|
+
examples: {
|
|
336
|
+
canneles: "Cannel\xE9s Bordelais",
|
|
337
|
+
empanadas: "Empanadas de Boeuf"
|
|
338
|
+
},
|
|
339
|
+
views: {
|
|
340
|
+
json: "Sortie JSON",
|
|
341
|
+
ast: "AST (Brut)",
|
|
342
|
+
jsonTree: "Arbre Interactif",
|
|
343
|
+
markdown: "Markdown",
|
|
344
|
+
preview: "Aper\xE7u (HTML)"
|
|
345
|
+
},
|
|
346
|
+
options: {
|
|
347
|
+
scaleTitle: "Mettre \xE0 l'\xE9chelle par ingr\xE9dient",
|
|
348
|
+
selectIngredient: "S\xE9lectionner un ingr\xE9dient...",
|
|
349
|
+
qty: "Qt\xE9",
|
|
350
|
+
unit: "Unit\xE9",
|
|
351
|
+
apply: "Appliquer",
|
|
352
|
+
bakersMath: "Pourcentage du boulanger",
|
|
353
|
+
enableBakersMath: "Activer le pourcentage du boulanger",
|
|
354
|
+
bakersMathDesc: "Affiche les ingr\xE9dients en % de la r\xE9f\xE9rence.",
|
|
355
|
+
hideAbsolute: "Masquer les poids absolus",
|
|
356
|
+
forceReference: "Forcer la r\xE9f\xE9rence :",
|
|
357
|
+
autoDetect: "Auto (d\xE9tecte @*)",
|
|
358
|
+
physicalAnalysis: "Analyse physique",
|
|
359
|
+
massStandardization: "Standardisation des masses",
|
|
360
|
+
massDesc: "Convertit toutes les quantit\xE9s d'ingr\xE9dients en grammes.",
|
|
361
|
+
yieldManagement: "Gestion du rendement",
|
|
362
|
+
nutrition: "Estimation nutritionnelle"
|
|
363
|
+
},
|
|
364
|
+
output: {
|
|
365
|
+
copy: "Copier dans le presse-papier",
|
|
366
|
+
loading: "Chargement du lecteur..."
|
|
367
|
+
},
|
|
368
|
+
warnings: {
|
|
369
|
+
warnings: "Avertissements",
|
|
370
|
+
warning: "Avertissement",
|
|
371
|
+
item: "\xC9l\xE9ment",
|
|
372
|
+
show: "Afficher"
|
|
373
|
+
},
|
|
374
|
+
analysisOptions: "Options d'Analyse",
|
|
375
|
+
analysis: "Analyse",
|
|
376
|
+
massNorm: "Standardisation des Masses",
|
|
377
|
+
yieldMgmt: "Gestion du Rendement (Masse Brute)",
|
|
378
|
+
nutritionEst: "Estimation Nutritionnelle",
|
|
379
|
+
statusValid: "Valide",
|
|
380
|
+
statusWarnings: "Avertissements",
|
|
381
|
+
copyBtn: "Copier dans le presse-papier"
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/locales/index.ts
|
|
386
|
+
var dictionaries = {
|
|
387
|
+
en: en3,
|
|
388
|
+
fr: fr3
|
|
389
|
+
};
|
|
390
|
+
function getDictionary(lang) {
|
|
391
|
+
const parts = (lang || "en").split("-");
|
|
392
|
+
const code = (parts[0] || "en").toLowerCase();
|
|
393
|
+
return dictionaries[code] || en3;
|
|
394
|
+
}
|
|
395
|
+
export {
|
|
396
|
+
TIME_BY_LANG,
|
|
397
|
+
TIME_DICTIONARIES,
|
|
398
|
+
TIME_GLOBAL,
|
|
399
|
+
UNIT_BY_LANG,
|
|
400
|
+
UNIT_DICTIONARIES,
|
|
401
|
+
UNIT_GLOBAL,
|
|
402
|
+
compileDictionary,
|
|
403
|
+
getAiLanguageInstruction,
|
|
404
|
+
getDefaultCategories,
|
|
405
|
+
getDictionary,
|
|
406
|
+
normalizeUnit,
|
|
407
|
+
resolveTimeUnit
|
|
408
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gram-lang/i18n",
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
|
+
"description": "Gram recipe i18n and unit normalization logic",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"gram",
|
|
13
|
+
"recipe",
|
|
14
|
+
"i18n",
|
|
15
|
+
"units"
|
|
16
|
+
],
|
|
17
|
+
"author": "abiwab",
|
|
18
|
+
"license": "GPL-3.0-or-later",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://codeberg.org/abiwab/gram.git",
|
|
22
|
+
"directory": "packages/i18n"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://codeberg.org/abiwab/gram/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://codeberg.org/abiwab/gram/src/branch/main/packages/i18n#readme",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup src/index.ts --format esm --dts --tsconfig ../../tsconfig.build.json",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"test": "bun test",
|
|
35
|
+
"prepublishOnly": "npm run build"
|
|
36
|
+
},
|
|
37
|
+
"type": "module"
|
|
38
|
+
}
|