Zheoni / cooklang-chef

A CLI to manage cooklang recipes
MIT License
68 stars 8 forks source link

Timer in a different language #10

Closed Openuser87 closed 1 year ago

Openuser87 commented 1 year ago

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.)

Zheoni commented 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?

Openuser87 commented 1 year ago

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?

Zheoni commented 1 year ago

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.

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 😅

Openuser87 commented 10 months ago

[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"]
Zheoni commented 10 months ago

The format was slightly updated. Here is an example https://github.com/cooklang/cooklang-rs/blob/main/units/spanish.toml

Openuser87 commented 10 months ago

Works again with new format, thank you!