Closed Openuser87 closed 1 year ago
I'm not sure of what you mean.
Units are displayed as written by default, and as the first loaded unit when converted. You can edit the units with a units configuration file. To load that config file there are several ways, the easiest way is just to put it in .cooklang/units.toml
next to your recipes. Documentation on that is not the best yet, but there's an example spanish units file here. You then can see the loaded units with chef units -l
.
Does that solve your problem or did I understand it wrong?
Thank you, I created .cooklang/units.toml
in my recipe directory and filled it with a test section for German language:
[extend.names]
s = ["Sekunde", "Sekunden"]
min = ["Minute", "Minuten"]
h = ["Stunde", "Stunden"]
d = ["Tag", "Tage"]
This works.
Is this the intended mechanism? If so, is there an initiative to contribute localizations of unit files like the one you mentioned? I see only Spanish version for now... Would one contribute such translations to cooklang-rs
directly?
Sure, you can submit a pull request in the cooklang-rs
repo with German units. Fill the following as needed for german. Add what you think is generally accepted in German.
[si.prefixes]
: to add SI prefixes like in spanish mili
with one l
for milli
. (you have to put all 6 even if they are empty)[si.symbol_prefixes]
: to add more SI symbols, I don't think this is very useful but was free to implement.[extend.names]
: the "long" names, like minute
or minutes
.[extend.symbols]
: the "short" names like min
[extend.aliases]
: for names that are not the exact ones, but can be used, like in spanish kilos
for kilograms
For names and symbols, you only add the base unit for SI units, like only gram
and not kilogram
. The rest will be extended from the si.prefixes
and si.symbol_prefixes
.
I know it's confusing, but it works 😅
[extend.names]
is not working anymore as of release 0.8.0:
unknown field `names`, expected `precedence` or `units`
Trying [extend.units]
does not work either:
invalid type: string "Sekunde", expected f64
What is the right field name?
My units.toml
:
[extend.names]
s = ["Sekunde", "Sekunden"]
min = ["Minute", "Minuten"]
h = ["Stunde", "Stunden"]
d = ["Tag", "Tage"]
The format was slightly updated. Here is an example https://github.com/cooklang/cooklang-rs/blob/main/units/spanish.toml
Works again with new format, thank you!
Is there a possibility to show timer units in a non-English language? If yes, which syntax has to be used?
(Using timer name still shows "minutes" in English.)