[Tex/LaTex] Is algorithm2e available in Spanish

algorithm2e

I'm trying this code copied from another post in TEX.SX
with the Spanish option, but some words appear in English, e.g. WHILE, FOR,… IF,…

Is it possible to change these to Spanish?

\documentclass[12pt,a4paper,x11names]{article}
%\renewcommand{\baselinestretch}{1.5} % interlineado de 1.5de la normativa del TFG  no usamos esto para poder usar el setspace y que el interlineado no afecte a las notas a íé de página.
\usepackage[top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm]{geometry}  % Margenes de la normativa TFG

\usepackage{setspace} 

\usepackage{lipsum,mwe}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{mathtools,amsmath,amsfonts,amssymb,latexsym}
\usepackage{eurosym}
\usepackage{graphicx}

\usepackage[ruled,vlined,lined,linesnumbered,spanish]{algorithm2e}

\begin{document}
\begin{algorithm}[H]
    \caption{Algoritmo del Enfiramiento Simulado}

    \KwData{la liste $L$ des naturels compris de $2$ à $N$.}
    \KwResult{la liste $P$ des nombres premiers compris entre $2$ et $N$.}
    \BlankLine
    \For{$i = 2$ \KwTo $N$}{
    \If{$i$ n'est pas barré dans la liste $L$}{
        Barrer dans la liste $L$ les mutltiples $ki$ où $k \geq 2$.
    }
    }
    \Return{la liste $P$ des nombres non barrés.}
\end{algorithm}

%\begin{algorithm}[h]
%\SetLine
%\linesnumbered
%\KwData{$\{ T_0,T_1,...,T_{imax}=T_{final}\}$}
%\end{algorithm}
\end{document}

Best Answer

Spanish is not supported out of the box, I'm afraid.

Here's what you should redefine; I leave the translation into Portuguese as found in the package, so Spanish people can adjust it (I marked this as Community Wiki).

\makeatletter
%%% this is from the \DeclareOptions part
\renewcommand{\listalgorithmcfname}{Lista de Algoritmos}%
\renewcommand{\algorithmcfname}{Algoritmo}%
\renewcommand{\algorithmautorefname}{algoritmo}%
\renewcommand{\algorithmcflinename}{linha}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedimento}%
\renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}%
\renewcommand{\procedureautorefname}{procedimento}%
\renewcommand{\functionautorefname}{fun\c{c}\~{a}o}%
\renewcommand{\algocf@languagechoosen}{portuguese}%
%%% this is from the switches further in the package
\SetKwInput{KwIn}{Entrada}%
\SetKwInput{KwOut}{Sa\'{i}da}%
\SetKwInput{KwData}{Dados}%
\SetKwInput{KwResult}{Resultado}%
\SetKw{KwTo}{at\'{e}}
\SetKw{KwRet}{retorna}%
\SetKw{Return}{retorna}%
\SetKwBlock{Begin}{in\'{i}cio}{fim}%
\SetKwRepeat{Repeat}{repita}{at\'{e}}%
%
\SetKwIF{If}{ElseIf}{Else}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}%
\SetKwFor{For}{para}{fa\c{c}a}{fim para}%
\SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para}
\SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}%
\SetKwFor{ForAll}{para todo}{fa\c{c}a}{fim para todo}%
\SetKwFor{While}{enquanto}{fa\c{c}a}{fim enqto}%
\makeatother

For reference, I add also the English translations

%%% this is from the \DeclareOptions part
\renewcommand{\listalgorithmcfname}{List of Algorithms}%
\renewcommand{\algorithmcfname}{Algorithm}%
\renewcommand{\algorithmautorefname}{algorithm}%
\renewcommand{\algorithmcflinename}{line}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedure}%
\renewcommand{\@algocf@funcname}{Function}%
\renewcommand{\procedureautorefname}{procedure}%
\renewcommand{\functionautorefname}{function}%
\renewcommand{\algocf@languagechoosen}{english}%
%%% this is from the switches further in the package
\SetKwInput{KwIn}{Input}%
\SetKwInput{KwOut}{Output}%
\SetKwInput{KwData}{Data}%
\SetKwInput{KwResult}{Result}%
\SetKw{KwTo}{to}
\SetKw{KwRet}{return}%
\SetKw{Return}{return}%
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
%
\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end switch}%
\SetKwFor{For}{for}{do}{end for}%
\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
\SetKwFor{ForEach}{foreach}{do}{end foreach}%
\SetKwFor{ForAll}{forall the}{do}{end forall}%
\SetKwFor{While}{while}{do}{end while}%
Related Question