Skip to content

Commit 5b8e1ba

Browse files
authored
Merge pull request #368 from gkreitz/150_i18n_for_sample_strings
Add translations for strings related to sample I/O in Swedish and Icelandic #150
2 parents ebbdc75 + cd88e6a commit 5b8e1ba

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

problemtools/templates/latex/problemset.cls

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@
8282
\newcommand*{\statementdirectory}[1]{\def\@statementdirectory{#1}}
8383
\newcommand*{\statementfilename}[1]{\def\@statementfilename{#1}}
8484
\newcommand*{\problemparentpath}[1]{\def\@problemparentpath{#1}}
85-
% \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}}
85+
\newcommand*{\problemlanguage}[1]{%
86+
\statementfilename{problem#1.tex}%
87+
\setproblemlanguagestrings{#1}%
88+
}
8789
\contestname{}
8890
\contestshortname{}
8991
\contestlogo{}
@@ -92,7 +94,6 @@
9294
\statementdirectory{problem_statement} % Default to the old standard directory on the off chance someone external uses problemset.cls
9395
\statementfilename{}
9496
\problemparentpath{}
95-
\problemlanguage{}
9697

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

@@ -250,11 +251,44 @@
250251

251252
%% Commands related to sample data
252253

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

259293
\newcommand{\formatsampleheader}[1]{\textsf{\textbf{#1}}}
260294

problemtools/templates/latex/template.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
\documentclass[plainproblems,noautoincludesamples]{problemset}
22

33
%% If you want to add comments in this file, you need to use %%, as it must be compatible with python's templates
4-
\problemlanguage{%(language)s} %% We inject problemlanguage to be backwards compatible with custom problemset.cls
4+
\problemlanguage{%(language)s}
55
\problemparentpath{%(problemparent)s}
66
\statementdirectory{%(statement_directory)s}
77
\statementfilename{%(statement_filename)s}

0 commit comments

Comments
 (0)