Skip to content

Commit aced430

Browse files
committed
Add translations for strings related to sample I/O in Swedish and Icelandic #150
1 parent bbfcf33 commit aced430

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

problemtools/templates/latex/problemset.cls

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@
8383
\newcommand*{\statementfilename}[1]{\def\@statementfilename{#1}}
8484
\newcommand*{\problemparentpath}[1]{\def\@problemparentpath{#1}}
8585
% \problemlanguge is solely for backwards compatibility on the off chance someone external uses problemset.cls. Probably not needed
86-
\newcommand*{\problemlanguage}[1]{\def\@problemlanguage{#1}\statementfilename{problem#1.tex}}
86+
\newcommand*{\problemlanguage}[1]{%
87+
\statementfilename{problem#1.tex}%
88+
\setproblemlanguagestrings{#1}%
89+
}
8790
\contestname{}
8891
\contestshortname{}
8992
\contestlogo{}
@@ -92,7 +95,6 @@
9295
\statementdirectory{problem_statement} % Default to the old standard directory on the off chance someone external uses problemset.cls
9396
\statementfilename{}
9497
\problemparentpath{}
95-
\problemlanguage{}
9698

9799
\newcommand{\@problempath}[1]{\ifx\@problemparentpath\@empty#1\else\@problemparentpath/#1\fi}
98100

@@ -250,11 +252,44 @@
250252

251253
%% Commands related to sample data
252254

253-
\newcommand{\sampleinputname}{Sample Input}
254-
\newcommand{\sampleoutputname}{Sample Output}
255-
\newcommand{\sampleinteractname}{Sample Interaction}
256-
\newcommand{\sampleinteractreadname}{Read}
257-
\newcommand{\sampleinteractwritename}{Write}
255+
% --- Translations ---
256+
% English (default)
257+
\newcommand{\@translation@en@sampleinputname}{Sample Input}
258+
\newcommand{\@translation@en@sampleoutputname}{Sample Output}
259+
\newcommand{\@translation@en@sampleinteractname}{Sample Interaction}
260+
\newcommand{\@translation@en@sampleinteractreadname}{Read}
261+
\newcommand{\@translation@en@sampleinteractwritename}{Write}
262+
263+
% Swedish
264+
\newcommand{\@translation@sv@sampleinputname}{Exempel på indata}
265+
\newcommand{\@translation@sv@sampleoutputname}{Exempel på utdata}
266+
\newcommand{\@translation@sv@sampleinteractname}{Exempel på interaktion}
267+
\newcommand{\@translation@sv@sampleinteractreadname}{Läs}
268+
\newcommand{\@translation@sv@sampleinteractwritename}{Skriv}
269+
270+
% Icelandic
271+
\newcommand{\@translation@is@sampleinputname}{Sýniinntak}
272+
\newcommand{\@translation@is@sampleoutputname}{Sýniúttak}
273+
\newcommand{\@translation@is@sampleinteractname}{Sýnisamskipti}
274+
\newcommand{\@translation@is@sampleinteractreadname}{Lestur}
275+
\newcommand{\@translation@is@sampleinteractwritename}{Skrif}
276+
% --- End Translations ---
277+
278+
\newcommand{\setproblemlanguagestrings}[1]{%
279+
\expandafter\ifx\csname @translation@#1@sampleinputname\endcsname\relax
280+
% Language not found, default to English
281+
\def\problemlanguageis{en}%
282+
\else
283+
% Language found
284+
\def\problemlanguageis{#1}%
285+
\fi
286+
\expandafter\let\expandafter\sampleinputname\csname @translation@\problemlanguageis @sampleinputname\endcsname
287+
\expandafter\let\expandafter\sampleoutputname\csname @translation@\problemlanguageis @sampleoutputname\endcsname
288+
\expandafter\let\expandafter\sampleinteractname\csname @translation@\problemlanguageis @sampleinteractname\endcsname
289+
\expandafter\let\expandafter\sampleinteractreadname\csname @translation@\problemlanguageis @sampleinteractreadname\endcsname
290+
\expandafter\let\expandafter\sampleinteractwritename\csname @translation@\problemlanguageis @sampleinteractwritename\endcsname
291+
}
292+
\setproblemlanguagestrings{en}
258293

259294
\newcommand{\formatsampleheader}[1]{\textsf{\textbf{#1}}}
260295

0 commit comments

Comments
 (0)