Open thorehusfeldt opened 5 years ago
Yes please! We've felt a need for this, and tried to do something like it for BOI 2018: https://github.com/nordicolympiad/baltic-olympiad-2018/tree/master/templates. Some phrases could be reused from there.
(That used latex includes though, which made the problems non-freestanding and Kattis people unhappy. Which we should have solved by copying the files into every problem folder, but that would have been a bit annoying for us, as well as making updates harder, and we were too stressed to do it.)
I see. What I’ve done so far is only to streamline the result of problem2pdf, which means localising exactly the 5 strings defined in problemset.cls
, such as \sampleinputname
, so this changes Sample Input 1 into Sämple Inpyt 1. If my understanding is correct, then the HTML pages are built via plasTex from pdf, so the HTML inherits those.
Many of the other strings you mention seems to “live” somewhere else (constraints, memorylimit), and I’m unsure what to override. To be honest, I don’t even know if the HTML page that ends up on a Kattis instance is produced by problemtools/problem2html , or if Kattis has its own version.
(The localisation that really triggers my OCD is what one should do about language-specific conventions for decimal numbers: “Förklaring för exempel 1: Den sammanlagda sträckningen är 14,233345”.)
Ah, yeah, the additional strings are probably a separate discussion from this (though they would be very useful). Time limit/memory limit were from when we created freestanding pdfs of the problems, those strings wouldn't appear on the web.
Kattis does use problem2html, and yes, the strings work with HTML as well.
I can submit a pull request from my branch any time, but maybe it’s premature.
It works with the problems that I’ve tried it on, including the warmups from the Swedish olympics.
I’ve tested with explicit selection form the command line, presence of various problem.xx.tex, single problem.sv.tex, without command line flags, etc. Seems to work, and degrade somewhat gracefully if it can’t find the proper files, but I may be naive about which environments it would be run in.
Problemtools allows problem descriptions in multiple languages, but the fixed headlines are hard-coded in English like this:
https://github.com/Kattis/problemtools/blob/063b68a98237773a11555c14fd2da07a25f68860/problemtools/templates/latex/problemset.cls#L222
It would be nice if those few headlines were localised, based on the two-letter language code of the problem description file.
One way I can think of doing that, implemented on https://github.com/thorehusfeldt/problemtools/tree/feat/i18n is to provide localisations in a yaml file in the template directory
/problemtools/templates/latex/strings.yaml
Then
/problemtools/templates/latex/template.tex
gets a few new placeholders:and the templating mechanism in
problemtools/template.py
takes care of replacing strings intoself.language
, falling back on English.Other approaches exist, such as using templates in
problemset.cls
. Or using babel. But the above works, and is quite light-weight.