Configuring DATA_DIR at runtime
Closed this issue · 5 comments
As far as I understood the code DATA_DIR
in task-maker-format/lib.rs
is configured from TM_DATA_DIR
at compile time.
It would be useful to support configuring this at runtime.
Use case: We want to use task-maker-rust
to generate hungarian statements for the IIOT round. Unfortunately the default cms-contest.cls
has some wrong word orders if simply translated to hungarian. A possible solution would be to overwrite that in /usr/share/task-maker-rust
, but it would be nicer to give task-maker-rust
a data dir via a command line argument or environment variable or something like that. Or we could just compile our own version with the appropriate TM_DATA_DIR
or files in data/
, but both of these seems a bit hacky. I just wanna use the packaged version xD
What are your thoughts?
I believe that a cleaner solution would be to use the language-if setup in cms-contest.cls to do the edits you need, no? (see https://github.com/edomora97/task-maker-rust/blob/master/data/statements/cms-contest.cls#L98 etc)
AFAIU the language is set from the name of the file - so italian.tex will go for italian, and portuguese.tex for portuguese, etc. We used this successfully for WEOI statements.
Yeah, that's what we planned to do. But some idioms look bad if translated directly from English with a fixed format, so for example we have something like "Page x of y" in which we can translate "Page" and "of", but in hungarian we would have to use a different format to not look silly. Thus we would need to edit cms-contest.cls
as well, if I'm not mistaken.
Yeah, that's what we planned to do. But some idioms look bad if translated directly from English with a fixed format, so for example we have something like "Page x of y" in which we can translate "Page" and "of", but in hungarian we would have to use a different format to not look silly. Thus we would need to edit
cms-contest.cls
as well, if I'm not mistaken.
I can think of two solutions for this:
- replace
\kw@Page\ \thepage\ \kw@of\ \pageref{LastPage}\hfill%
with\if@hungarian <something> \else \kw@Page\ \thepage\ \kw@of\ \pageref{LastPage}\hfill% \fi
(or similar - (probably a better solution) remove
\def\kw@Page{Page}\def\kw@of{of}
entirely, replace it with\def\kw@PageXofY#1#2{Page\ #1\ of\ #2}
, and replace\kw@Page\ \thepage\ \kw@of\ \pageref{LastPage}\hfill%
with\kw@pageXofY{\thepage}{\pageref{LastPage}}\hfill%
(and similarly for other languages)
Ohh okay, option 2 looks good. I assumed that this cls is kinda fixed in the repo. I will consult with my colleague if we need to generalize any other stuff, and we will create a PR with all the changes necessary.
Ohh okay, option 2 looks good. I assumed that this cls is kinda fixed in the repo. I will consult with my colleague if we need to generalize any other stuff, and we will create a PR with all the changes necessary.
Sounds good to me!
We have not needed to modify the cls, but that doesn't mean we wouldn't want to if it is useful :)