Mercurial > hgbook
comparison es/template.tex @ 569:012631b248de
translated some templates chapter paragraphs
author | Igor Támara <igor@tamarapatino.org> |
---|---|
date | Sun, 28 Dec 2008 00:27:39 -0500 |
parents | b05e35d641e4 |
children | 1b8b19825994 |
comparison
equal
deleted
inserted
replaced
559:a1b640641d37 | 569:012631b248de |
---|---|
1 \chapter{Customising the output of Mercurial} | 1 \chapter{Personalizar los mensajes de Mercurial} |
2 \label{chap:template} | 2 \label{chap:template} |
3 | 3 |
4 Mercurial provides a powerful mechanism to let you control how it | 4 Mercurial provee un poderoso mecanismo que permite controlar como |
5 displays information. The mechanism is based on templates. You can | 5 despliega la información. El mecanismo se basa en plantillas. Puede |
6 use templates to generate specific output for a single command, or to | 6 usar plantillas para generar salida específica para una orden |
7 customise the entire appearance of the built-in web interface. | 7 particular o para especificar la visualización completa de la interfaz |
8 | 8 web embebida. |
9 \section{Using precanned output styles} | 9 |
10 \section{Usar estilos que vienen con Mercurial} | |
10 \label{sec:style} | 11 \label{sec:style} |
11 | 12 |
12 Packaged with Mercurial are some output styles that you can use | 13 Hay ciertos estilos listos que vienen con Mercurial. Un estilo es |
13 immediately. A style is simply a precanned template that someone | 14 simplemente una plantilla predeterminada que alguien escribió e |
14 wrote and installed somewhere that Mercurial can find. | 15 instaló en un sitio en el cual Mercurial puede encontrarla. |
15 | 16 |
16 Before we take a look at Mercurial's bundled styles, let's review its | 17 Antes de dar un vistazo a los estilos que trae Mercurial, revisemos su |
17 normal output. | 18 salida usual. |
18 | 19 |
19 \interaction{template.simple.normal} | 20 \interaction{template.simple.normal} |
20 | 21 |
21 This is somewhat informative, but it takes up a lot of space---five | 22 Es en cierta medida informativa, pero ocupa mucho espacio---cinco |
22 lines of output per changeset. The \texttt{compact} style reduces | 23 líneas de salida por cada conjunto de cambios. El estilo |
23 this to three lines, presented in a sparse manner. | 24 \texttt{compact} lo reduce a tres líneas, presentadas de forma |
25 suscinta. | |
24 | 26 |
25 \interaction{template.simple.compact} | 27 \interaction{template.simple.compact} |
26 | 28 |
27 The \texttt{changelog} style hints at the expressive power of | 29 El estilo de la \texttt{bitácora de cambios} vislumbra el poder |
28 Mercurial's templating engine. This style attempts to follow the GNU | 30 expresivo del sistema de plantillas de Mercurial. Este estilo busca |
29 Project's changelog guidelines\cite{web:changelog}. | 31 seguir los estándares de bitácora de cambios del proyecto |
32 GNU\cite{web:changelog}. | |
30 | 33 |
31 \interaction{template.simple.changelog} | 34 \interaction{template.simple.changelog} |
32 | 35 |
33 You will not be shocked to learn that Mercurial's default output style | 36 No es una sorpresa que el estilo predeterminado de Mercurial se llame |
34 is named \texttt{default}. | 37 \texttt{default}\ndt{predeterminado}. |
35 | 38 |
36 \subsection{Setting a default style} | 39 \subsection{Especificar un estilo predeterminado} |
37 | 40 |
38 You can modify the output style that Mercurial will use for every | 41 Puede modificar el estilo de presentación que Mercurial usará para |
39 command by editing your \hgrc\ file, naming the style you would | 42 toda orden vía el fichero \hgrc\, indicando el estilo que prefiere |
40 prefer to use. | 43 usar. |
41 | 44 |
42 \begin{codesample2} | 45 \begin{codesample2} |
43 [ui] | 46 [ui] |
44 style = compact | 47 style = compact |
45 \end{codesample2} | 48 \end{codesample2} |
46 | 49 |
47 If you write a style of your own, you can use it by either providing | 50 Si escribe un estilo, puede usarlo bien sea proveyendo la ruta a su |
48 the path to your style file, or copying your style file into a | 51 fichero de estilo o copiando su fichero de estilo a un lugar en el |
49 location where Mercurial can find it (typically the \texttt{templates} | 52 cual Mercurial pueda encontrarlo(típicamente el subdirectorio |
50 subdirectory of your Mercurial install directory). | 53 \texttt{templates} de su directorio de instalación de Mercurial). |
51 | 54 |
52 \section{Commands that support styles and templates} | 55 \section{Órdenes que soportan estilos y plantillas} |
53 | 56 |
54 All of Mercurial's ``\texttt{log}-like'' commands let you use styles | 57 Todas las órdenes de Mercurial``relacionadas con \texttt{log}'' le |
55 and templates: \hgcmd{incoming}, \hgcmd{log}, \hgcmd{outgoing}, and | 58 permiten usar estilos y plantillas: \hgcmd{incoming}, \hgcmd{log}, |
56 \hgcmd{tip}. | 59 \hgcmd{outgoing} y \hgcmd{tip}. |
57 | 60 |
58 As I write this manual, these are so far the only commands that | 61 Al momento de la escritura del manual estas son las únicas órdenes que |
59 support styles and templates. Since these are the most important | 62 soportan estilos y plantillas. Dado que son las órdenes más |
60 commands that need customisable output, there has been little pressure | 63 importantes que necesitan personalización, no ha habido muchas |
61 from the Mercurial user community to add style and template support to | 64 solicitudes desde la comunidad de usuarios de Mercurial para añadir |
62 other commands. | 65 soporte de plantillas y estilos a otras órdenes. |
63 | 66 |
64 \section{The basics of templating} | 67 \section{Cuestiones básicas de plantillas} |
65 | 68 |
66 At its simplest, a Mercurial template is a piece of text. Some of the | 69 Una plantilla de Mercurial es sencillamente una pieza de texto. |
67 text never changes, while other parts are \emph{expanded}, or replaced | 70 Cierta porción nunca cambia, otras partes se \emph{expanden}, o |
68 with new text, when necessary. | 71 reemplazan con texto nuevo cuando es necesario. |
69 | 72 |
70 Before we continue, let's look again at a simple example of | 73 Antes de continuar, veamos de nuevo un ejemplo sencillo de la salida |
71 Mercurial's normal output. | 74 usual de Mercurial: |
72 | 75 |
73 \interaction{template.simple.normal} | 76 \interaction{template.simple.normal} |
74 | 77 |
75 Now, let's run the same command, but using a template to change its | 78 Ahora, ejecutemos la misma orden, pero usemos una plantilla para |
76 output. | 79 modificar su salida: |
77 | 80 |
78 \interaction{template.simple.simplest} | 81 \interaction{template.simple.simplest} |
79 | 82 |
80 The example above illustrates the simplest possible template; it's | 83 El ejemplo anterior ilustra la plantilla más sencilla posible; es |
81 just a piece of static text, printed once for each changeset. The | 84 solamente una porción estática de código que se imprime una vez por |
82 \hgopt{log}{--template} option to the \hgcmd{log} command tells | 85 cada conjunto de cambios. La opción \hgopt{log}{--template} de la |
83 Mercurial to use the given text as the template when printing each | 86 orden \hgcmd{log} indica a Mercurial usar el texto dado como la |
84 changeset. | 87 plantilla cuando se imprime cada conjunto de cambios. |
85 | 88 |
86 Notice that the template string above ends with the text | 89 Observe que la cadena de plantilla anterior termina con el texto |
87 ``\Verb+\n+''. This is an \emph{escape sequence}, telling Mercurial | 90 ``\Verb+\n+''. Es una \emph{secuencia de control}, que le indica a |
88 to print a newline at the end of each template item. If you omit this | 91 Mercurial imprimira una nueva línea al final de cada objeto de la |
89 newline, Mercurial will run each piece of output together. See | 92 plantilla. Si omite esta nueva línea, Mercurial colocará cada pieza |
90 section~\ref{sec:template:escape} for more details of escape sequences. | 93 de salida seguida. Si desea más detalles acerca de secuencias de |
91 | 94 control, vea la sección~\ref{sec:template:escape}. |
92 A template that prints a fixed string of text all the time isn't very | 95 |
93 useful; let's try something a bit more complex. | 96 Una plantilla que imprime una cadena fija de texto siempre no es muy |
97 útil; intentemos algo un poco más complejo. | |
94 | 98 |
95 \interaction{template.simple.simplesub} | 99 \interaction{template.simple.simplesub} |
96 | 100 |
97 As you can see, the string ``\Verb+{desc}+'' in the template has been | 101 Como puede ver, la cadena ``\Verb+{desc}+'' en la plantilla ha sido |
98 replaced in the output with the description of each changeset. Every | 102 reemplazada en la salida con la descricipción de cada conjunto de |
99 time Mercurial finds text enclosed in curly braces (``\texttt{\{}'' | 103 cambios. Cada vez que Mercurial encuentra texto encerrado entre |
100 and ``\texttt{\}}''), it will try to replace the braces and text with | 104 corchetes(``\texttt{\{}'' y ``\texttt{\}}''), intentará reemplazar los |
101 the expansion of whatever is inside. To print a literal curly brace, | 105 corchetes y el texto con la expansión de lo que sea está adentro. |
102 you must escape it, as described in section~\ref{sec:template:escape}. | 106 Para imprimir un corchete de forma literal, debe escaparlo, como se |
103 | 107 describe en la sección~\ref{sec:template:escape}. |
104 \section{Common template keywords} | 108 |
109 \section{Palabras claves más comunes en las plantillas} | |
105 \label{sec:template:keyword} | 110 \label{sec:template:keyword} |
106 | 111 |
107 You can start writing simple templates immediately using the keywords | 112 Puede empezar a escribir plantillas sencillas rápidamente con las |
108 below. | 113 palabras claves descritas a continuación: |
109 | 114 |
110 \begin{itemize} | 115 \begin{itemize} |
111 \item[\tplkword{author}] String. The unmodified author of the changeset. | 116 \item[\tplkword{author}] Cadena. El autor NO modificado del conjunto |
112 \item[\tplkword{branches}] String. The name of the branch on which | 117 de cambios. |
113 the changeset was committed. Will be empty if the branch name was | 118 \item[\tplkword{branches}] Cadena. El nombre de la rama en la cual se |
119 consignó el conjunto de cambios. Será vacía si el nombre de la rama es | |
114 \texttt{default}. | 120 \texttt{default}. |
115 \item[\tplkword{date}] Date information. The date when the changeset | 121 \item[\tplkword{date}] Información de fecha. La fecha en la cual se |
116 was committed. This is \emph{not} human-readable; you must pass it | 122 consignó el conjunto de cambios. \emph{No} es legible por un |
117 through a filter that will render it appropriately. See | 123 humano, debe pasarla por un firltro que la desplegará |
118 section~\ref{sec:template:filter} for more information on filters. | 124 apropiadamente. En la sección~\ref{sec:template:filter} hay más |
119 The date is expressed as a pair of numbers. The first number is a | 125 detalles acerca de filtros. La fecha se expresa como un par de |
120 Unix UTC timestamp (seconds since January 1, 1970); the second is | 126 números. El primer número corresponde a una marca de tiempo UNIX |
121 the offset of the committer's timezone from UTC, in seconds. | 127 UTC(segundos desde el primero de enero de 1970); la segunda es el |
122 \item[\tplkword{desc}] String. The text of the changeset description. | 128 corrimiento horario de la zona horaria del UTC en la cual se encontraba |
123 \item[\tplkword{files}] List of strings. All files modified, added, or | 129 quien hizo la consignación, en segundos. |
124 removed by this changeset. | 130 \item[\tplkword{desc}] Cadena. La descripción en texto del conjunto |
125 \item[\tplkword{file\_adds}] List of strings. Files added by this | 131 de cambios. |
126 changeset. | 132 \item[\tplkword{files}] Lista de cadenas. Todos los ficheros |
127 \item[\tplkword{file\_dels}] List of strings. Files removed by this | 133 modificados, adicionados o eliminados por este conjunto de cambios. |
128 changeset. | 134 \item[\tplkword{file\_adds}] Lista de cadenas. Ficheros adicionados |
129 \item[\tplkword{node}] String. The changeset identification hash, as a | 135 por este conjunto de cambios. |
130 40-character hexadecimal string. | 136 \item[\tplkword{file\_dels}] Lista de cadenas. Ficheros eliminados |
131 \item[\tplkword{parents}] List of strings. The parents of the | 137 por este conjunto de cambios. |
132 changeset. | 138 \item[\tplkword{node}] Cadena. El hash de identificación de este |
133 \item[\tplkword{rev}] Integer. The repository-local changeset revision | 139 conjunto de cambios como una cadena hexadecimal de 40 caracteres. |
134 number. | 140 \item[\tplkword{parents}] Lista de cadenas. Los ancestros del |
135 \item[\tplkword{tags}] List of strings. Any tags associated with the | 141 conjunto de cambios. |
136 changeset. | 142 \item[\tplkword{rev}] Entero. El número de revisión del repositorio |
137 \end{itemize} | 143 local. |
138 | 144 \item[\tplkword{tags}] Lista de cadenas. Todas las etiquetas |
139 A few simple experiments will show us what to expect when we use these | 145 asociadas al conjunto de cambios. |
140 keywords; you can see the results in | 146 \end{itemize} |
141 figure~\ref{fig:template:keywords}. | 147 |
148 Unos experimentos sencillos nos mostrarán qué esperar cuando usamos | |
149 estas palabras claves; puede ver los resultados en la | |
150 figura~\ref{fig:template:keywords}. | |
142 | 151 |
143 \begin{figure} | 152 \begin{figure} |
144 \interaction{template.simple.keywords} | 153 \interaction{template.simple.keywords} |
145 \caption{Template keywords in use} | 154 \caption{Template keywords in use} |
146 \label{fig:template:keywords} | 155 \label{fig:template:keywords} |
147 \end{figure} | 156 \end{figure} |
148 | 157 |
149 As we noted above, the date keyword does not produce human-readable | 158 Como mencionamos anteriormente, la palabra clave de fecha no produce |
150 output, so we must treat it specially. This involves using a | 159 salida legible por un humano, debemos tratarla de forma especial. |
151 \emph{filter}, about which more in section~\ref{sec:template:filter}. | 160 Esto involucra usar un \emph{filtro}, acerca de lo cual hay más en la |
161 sección~\ref{sec:template:filter}. | |
152 | 162 |
153 \interaction{template.simple.datekeyword} | 163 \interaction{template.simple.datekeyword} |
154 | 164 |
155 \section{Escape sequences} | 165 \section{Secuencias de Control} |
156 \label{sec:template:escape} | 166 \label{sec:template:escape} |
157 | 167 |
158 Mercurial's templating engine recognises the most commonly used escape | 168 El motor de plantillas de Mercurial reconoce las secuencias de control |
159 sequences in strings. When it sees a backslash (``\Verb+\+'') | 169 más comunmente usadas dentro de las cadenas. Cuando ve un backslash |
160 character, it looks at the following character and substitutes the two | 170 (``\Verb+\+''), ve el caracter siguiente y sustituye los dos |
161 characters with a single replacement, as described below. | 171 caracteres con un reemplazo sencillo, como se describe a continuación: |
162 | 172 |
163 \begin{itemize} | 173 \begin{itemize} |
164 \item[\Verb+\textbackslash\textbackslash+] Backslash, ``\Verb+\+'', | 174 \item[\Verb+\textbackslash\textbackslash+] Backslash, ``\Verb+\+'', |
165 ASCII~134. | 175 ASCII~134. |
166 \item[\Verb+\textbackslash n+] Newline, ASCII~12. | 176 \item[\Verb+\textbackslash n+] Nueva línea, ASCII~12. |
167 \item[\Verb+\textbackslash r+] Carriage return, ASCII~15. | 177 \item[\Verb+\textbackslash r+] Cambio de línea, ASCII~15. |
168 \item[\Verb+\textbackslash t+] Tab, ASCII~11. | 178 \item[\Verb+\textbackslash t+] Tab, ASCII~11. |
169 \item[\Verb+\textbackslash v+] Vertical tab, ASCII~13. | 179 \item[\Verb+\textbackslash v+] Tab Vertical, ASCII~13. |
170 \item[\Verb+\textbackslash \{+] Open curly brace, ``\Verb+{+'', ASCII~173. | 180 \item[\Verb+\textbackslash \{+] Corchete abierto, ``\Verb+{+'', ASCII~173. |
171 \item[\Verb+\textbackslash \}+] Close curly brace, ``\Verb+}+'', ASCII~175. | 181 \item[\Verb+\textbackslash \}+] Corchete cerrado, ``\Verb+}+'', ASCII~175. |
172 \end{itemize} | 182 \end{itemize} |
173 | 183 |
174 As indicated above, if you want the expansion of a template to contain | 184 Como se indicó arriba, si desea que la expansión en una plantilla |
175 a literal ``\Verb+\+'', ``\Verb+{+'', or ``\Verb+{+'' character, you | 185 contenga un caracter literal ``\Verb+\+'', ``\Verb+{+'', o |
176 must escape it. | 186 ``\Verb+{+'', debe escaparlo. |
177 | 187 |
178 \section{Filtering keywords to change their results} | 188 \section{Uso de filtros con palabras claves} |
179 \label{sec:template:filter} | 189 \label{sec:template:filter} |
180 | 190 |
181 Some of the results of template expansion are not immediately easy to | 191 Algunos de los resultados de la expansión de la plantilla no son |
182 use. Mercurial lets you specify an optional chain of \emph{filters} | 192 fáciles de usar de inmediato. Mercurial le permite especificar una |
183 to modify the result of expanding a keyword. You have already seen a | 193 cadena de \emph{filtros} opcionales para modificar el resultado de |
184 common filter, \tplkwfilt{date}{isodate}, in action above, to make a | 194 expandir una palabra clave. Ya ha visto el filtro usual |
185 date readable. | 195 \tplkwfilt{date}{isodate} en acción con anterioridad para hacer |
186 | 196 legible la fecha. |
187 Below is a list of the most commonly used filters that Mercurial | 197 |
188 supports. While some filters can be applied to any text, others can | 198 A continuación hay una lista de los filtros de Mercurial más |
189 only be used in specific circumstances. The name of each filter is | 199 comunmente usados. Ciertos filtros pueden aplicarse a cualquier |
190 followed first by an indication of where it can be used, then a | 200 texto, otros pueden usarse únicamente en circunstancias específicas. |
191 description of its effect. | 201 El nombre de cada filtro está seguido de la indicación de dónde puede |
192 | 202 ser usado y una descripción de su efecto. |
193 \begin{itemize} | 203 |
194 \item[\tplfilter{addbreaks}] Any text. Add an XHTML ``\Verb+<br/>+'' | 204 \begin{itemize} |
195 tag before the end of every line except the last. For example, | 205 \item[\tplfilter{addbreaks}] Cualquier texto. Añade una etiqueta XHTML |
196 ``\Verb+foo\nbar+'' becomes ``\Verb+foo<br/>\nbar+''. | 206 ``\Verb+<br/>+'' antes del final de cada línea excepto en la final. |
197 \item[\tplkwfilt{date}{age}] \tplkword{date} keyword. Render the | 207 Por ejemplo, ``\Verb+foo\nbar+'' se convierte en ``\Verb+foo<br/>\nbar+''. |
198 age of the date, relative to the current time. Yields a string like | 208 \item[\tplkwfilt{date}{age}] palabra clave \tplkword{date}. Muestra |
209 la edad de la fecha, relativa al tiempo actual. Ofrece una cadena como | |
199 ``\Verb+10 minutes+''. | 210 ``\Verb+10 minutes+''. |
200 \item[\tplfilter{basename}] Any text, but most useful for the | 211 \item[\tplfilter{basename}] Cualquier texto, pero de utilidad sobre |
201 \tplkword{files} keyword and its relatives. Treat the text as a | 212 todo en palabras claves relativas a \tplkword{ficheros}. Trata el |
202 path, and return the basename. For example, ``\Verb+foo/bar/baz+'' | 213 texto como una ruta, retornando el nombre base. Por ejemplo, |
203 becomes ``\Verb+baz+''. | 214 ``\Verb+foo/bar/baz+'', se convierte en ``\Verb+baz+''. |
204 \item[\tplkwfilt{date}{date}] \tplkword{date} keyword. Render a date | 215 \item[\tplkwfilt{date}{date}] \tplkword{date} keyword. Render a date |
205 in a similar format to the Unix \tplkword{date} command, but with | 216 in a similar format to the Unix \tplkword{date} command, but with |
206 timezone included. Yields a string like | 217 timezone included. Yields a string like |
207 ``\Verb+Mon Sep 04 15:13:13 2006 -0700+''. | 218 ``\Verb+Mon Sep 04 15:13:13 2006 -0700+''. |
208 \item[\tplkwfilt{author}{domain}] Any text, but most useful for the | 219 \item[\tplkwfilt{author}{domain}] Any text, but most useful for the |