[Tex/LaTex] Listings package with caption legend in spanish

captionslanguageslistings

I'm using the listings package and would like to translate the caption text displayed to Spanish, so instead of Listing 1: Dummy label it will display Listado 1: Dummy label.

This is my code:

\documentclass[11pt]{article}   % list options between brackets
\usepackage[spanish]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{hyperref} %Links
\usepackage{verbatim}
\usepackage{listings}
\lstset{ %
%  language=Octave,                % the language of the code
  basicstyle=\scriptsize,           % the size of the fonts that are used for the code
  frame=single,                   % adds a frame around the code
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  escapeinside={\%*}{*)},            % if you want to add LaTeX within your code
  extendedchars=true,
}



\begin{document}

\begin{lstlisting}
{
"identificador" : "22587"
"nombre" : "Visita guiada para conocer las aves del Botanico"
"descripcion" : "... Los domingos 8 de julio, 12 de agosto y 9 de septiembre (a las 10.30 horas) ..."
"dia-de-inicio" : "2012-07-08 10:30:00 +0200"
"dia-de-fin" : "2012-09-09 10:30:00 +0200"
}
\end{lstlisting}


\end{document}

Best Answer

We can redefine \lstlistingname which is the caption label for listings:

\documentclass[11pt]{article}   % list options between brackets

\usepackage[spanish]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{hyperref} %Links
\usepackage{verbatim}
\usepackage{listings}

\renewcommand{\lstlistingname}{Listado}

\lstset{ %
%  language=Octave,                % the language of the code
  basicstyle=\scriptsize,           % the size of the fonts that are used for the code
  frame=single,                   % adds a frame around the code
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  escapeinside={\%*}{*)},            % if you want to add LaTeX within your code
  extendedchars=true,
}  

\begin{document}

\begin{lstlisting}[caption=Evento celebrado en días no consecutivos]
{
"identificador" : "22587"
"nombre" : "Visita guiada para conocer las aves del Botanico"
"descripcion" : "... Los domingos 8 de julio, 12 de agosto y 9 de septiembre (a las 10.30 horas) ..."
"dia-de-inicio" : "2012-07-08 10:30:00 +0200"
"dia-de-fin" : "2012-09-09 10:30:00 +0200"
}
\end{lstlisting}

\end{document}

Listing

Hope it helps. :)

Related Question