Difference between revisions of "Format specifiers-es"

From AMule Project FAQ
Jump to: navigation, search
m (Corrected Spelling of Español in language selection)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
'''MEN AT WORK, PLEASE DONT LINK IT, I WILL LINK IT WHEN FINISHED, THANX ;)'''
 
'''MEN AT WORK, PLEASE DONT LINK IT, I WILL LINK IT WHEN FINISHED, THANX ;)'''
 +
fdo. crax
  
 
<center>
 
<center>
[[Format_specifiers|Inglés]] | '''Español'''
+
[[Format_specifiers|English]] |  
 +
'''Espa&ntilde;ol'''
 
</center>
 
</center>
  
Line 10: Line 12:
 
[[aMule]] se realiza en el lenguaje de programación [http://www.icce.rug.nl/documents/cplusplus C++]. Este lenguaje permite gestionar de una manera sencilla los caracteres pero en algunos casos es necesario recurrir a algún que otro truco.
 
[[aMule]] se realiza en el lenguaje de programación [http://www.icce.rug.nl/documents/cplusplus C++]. Este lenguaje permite gestionar de una manera sencilla los caracteres pero en algunos casos es necesario recurrir a algún que otro truco.
  
Cuando se está [[translations-es|traduciendo el aMule]], puedes encontrarte con  cosas extrañas. Algunas veces serán simplemente tipos de letra, pero en otras ocasiónes se incluyen con unpropósito determinado.
+
En el caso de que estés realizando una [[translations-es|traducción de aMule]], lo mas probable es que te encuentres una series de “cosas extrañas”. Algunas veces serán simplemente tipos de letra, pero en otras ocasiones, éstas se incluyen con un propósito determinado.
  
Este documento es '''obligatorio''' para alguien que desea o esta [[translations|traduciendo el  aMule]]. En este documento se describen todos casos de grupos de caracteres que '''nunca''' deben modificarse.
+
Este documento es '''necesario y obligado''' para alguien que desea o esta [[translations-es|traduciendo el  aMule]]. En este documento se describen todos casos de grupos de caracteres que '''nunca''' deben modificarse.
  
 
Por la tanto en este documento puedes encontrar la descripción de los grupos de caracteres que '''no''' debes modificar y cual es la explicación de cada uno de ellos..
 
Por la tanto en este documento puedes encontrar la descripción de los grupos de caracteres que '''no''' debes modificar y cual es la explicación de cada uno de ellos..
  
== Códigos ==
+
== Códigos especiales ==
  
=== Códigos [http://www.ecma-international.org/publications/standards/Ecma-006.htm ASCII] que no se representan ===
+
=== Códigos especiales [http://www.ecma-international.org/publications/standards/Ecma-006.htm ASCII] no representables ===
  
 
Son códigos que representan caracteres en código  [http://www.ecma-international.org/publications/standards/Ecma-006.htm ASCII] los cuales no pueden ser escritos con el teclado.
 
Son códigos que representan caracteres en código  [http://www.ecma-international.org/publications/standards/Ecma-006.htm ASCII] los cuales no pueden ser escritos con el teclado.
*''\a'' -> Normalmente produce una alerta sonora (en algunso casos visual) como un pitido
+
 
 +
*''\a'' -> Normalmente produce una alerta sonora (en algún  caso visual) como un pitido
 
*''\b'' -> Regresa hacia atrás un caracter
 
*''\b'' -> Regresa hacia atrás un caracter
*''\f'' -> En la mayoría de los sistemas limpia la pantalla.
+
*''\f'' -> En la mayoría de los sistemas realiza una limpieza de la pantalla.
*''\n'' -> Finaliza la linea actual y comienza una nueva, situando el cursor al inicio de la nueva linea.
+
*''\n'' -> Finaliza la línea actual y comienza una nueva, situando el cursor al inicio de la nueva línea.
*''\r'' -> Va al inicio de la linea actual
+
*''\r'' -> Va al inicio de la línea actual
 
*''\t'' -> Tabulación horizontal.
 
*''\t'' -> Tabulación horizontal.
*''\v'' -> Tabulación verical.
+
*''\v'' -> Tabulación vertical.
*''\<octal digits>'' -> Mortrará ''octal digits'' en octal
+
*''\<octal digits>'' -> Mostrará ''octal digits'' en octal
*''\x<hex digits>'' -> Mortrará el valor ''hex digits'' en hexadecimal
+
*''\x<hex digits>'' -> Mostrará el valor ''hex digits'' en hexadecimal
  
=== Códigos de desambiguación ===
+
=== Códigos especiales de desambiguación ===
  
Los siguientes no son caracteres que no se puedan representar mediante el teclado, pero debido a las limitaciones en el lenguaje de programación [http://www.icce.rug.nl/documents/cplusplus C++] son necesarios para utilizarlos como:
+
Los siguientes no son caracteres que no se puedan escribir mediante el teclado, pero debido a las limitaciones en el lenguaje de programación [http://www.icce.rug.nl/documents/cplusplus C++] son necesarios para utilizarlos como:
 
*''\?'' -> muestra un signo de interrogación ( ''?'' ) para evitar traducciones tipográficas (no todos los compiladores soportan la traducción tipográfica, por lo que no siempre es necesario)
 
*''\?'' -> muestra un signo de interrogación ( ''?'' ) para evitar traducciones tipográficas (no todos los compiladores soportan la traducción tipográfica, por lo que no siempre es necesario)
 
*''\\'' -> Muestra un slash ( ''\'' )
 
*''\\'' -> Muestra un slash ( ''\'' )
Line 41: Line 44:
 
=== Ejemplos ===
 
=== Ejemplos ===
  
A continuación tenemos uns ejemplos de los códigos mostrados anteriormente. They are listed as couples of code-line + output. So, the first line represents the line in the way it is written into the [http://www.icce.rug.nl/documents/cplusplus C++] code and the second line (or group of lines if it needs more than one line) represents how that [http://www.icce.rug.nl/documents/cplusplus C++] code line is displayed on execution:
+
A continuación tenemos unos ejemplos de los códigos mostrados anteriormente. Se muestran en parejas incluyendo la línea de código y la salida que tendrá dicha línea de código en el sistema.. En otras palabras, la primera línea representa el código  [http://www.icce.rug.nl/documents/cplusplus C++] y la segunda línea  (o grupo de línea en el caso de que sea necesario explicarlo en más de una línea) explica como el código  [http://www.icce.rug.nl/documents/cplusplus C++] de la línea anterior se ejecuta en el sistema:
  
**Code line: ''"[[User:Jacobo221|Jacobo221]] is an angel\aOh, true, I am not."''
+
** Línea de código: ''"[[User:Jacobo221|Jacobo221]] is an angel\aOh, true, I am not."''
**Output: ''[[User:Jacobo221|Jacobo221]] is an angelOh, true, I am not'' (A beep will be heard right after displaying the word ''angel'' and the next word (''Oh'') will not be displayed untill the beep finishes)
+
**Salida: ''[[User:Jacobo221|Jacobo221]] is an angelOh, true, I am not'' (Se escuchará un pitido justo después de la palabra ''angel'' y la siguiente palabra no (''Oh'') no se mostrará hasta que no finalice el pitido)
  
**Code line: ''"I have 6\b5 fingers in my right hand"''
+
**Línea de código: ''"I have 6\b5 fingers in my right hand"''
**Output: ''I have 5 fingers in my right hand''
+
**Salida: ''I have 5 fingers in my right hand''
  
**Code line: ''"Where is the <RETURN> key???\nAh, here it is!"''
+
**Línea de código: ''"Where is the <RETURN> key???\nAh, here it is!"''
**Output: ''Where is the <RETURN> key???''<br>''Ah, here it is!''
+
**Salida: ''Where is the <RETURN> key???''<br>''Ah, here it is!''
  
**Code line: ''"I am a BIG lier\rI'm married with Marilyn Monroe"''
+
** Línea de código: ''"I am a BIG lier\rI'm married with Marilyn Monroe"''
**Output: ''I'm married with Marilyn Monroe''
+
**Salida: ''I'm married with Marilyn Monroe''
  
**Code line: ''"\141\115\165\x6C\x65"''
+
** Línea de código: ''"\141\115\165\x6C\x65"''
**Output: ''aMule'' (Notice that the octal value of ''a'' in the [http://www.ecma-international.org/publications/standards/Ecma-006.htm ASCII] codeset is 141, the octal value of ''M'' is 115, the octal value of ''u'' is 165, the hexadecimal value of ''l'' is 6C and the hexadecimal value of ''e'' is 65)
+
**Salida: ''aMule'' (Ten en cuenta que el valor en octal de ''a'' en código [http://www.ecma-international.org/publications/standards/Ecma-006.htm ASCII] es 141, el valor en octal ''M'' es 115, el valor en octal de ''u'' es 165, el valor en  hexadecimal de''l'' es 6C y por último el valor hexadecimal de ''e'' es 65)
  
**Code line: ''"Isn\'t it complicated to use the \" and \\ characters\?"''
+
** Línea de código: ''"Isn\'t it complicated to use the \" and \\ characters\?"''
**Output: ''Isn't it complicated to use the " and \ characters?''
+
**Salida: ''Isn't it complicated to use the " and \ characters?''
  
== Format specifiers ==
+
== Códigos de formateo ==
  
=== Basic format specifiers ===
+
=== Códigos de formateo básico ===
  
Format specifiers are groups of characters which will be substituted with something else. The format specifier itself specified which type of data it will be substituted with:
+
Los códigos de formateo son grupos de caracteres que serán sustituidos por otros datos. El código de formato mismo especifica por que tipo de datos será sustituido:
*''%d'' -> Decimal value (signed integer type). Equivalen to %i
+
 
*''%i'' -> Decimal value (signed integer type). Equivalen to %d
+
*''%d'' -> Valor decimal (signed integer type). Equivalente a %i
*''%u'' -> Natural number (unsigned integer type).
+
*''%i'' -> Valor decimal (signed integer type). Equivalente a %d
*''%x'' -> Hexadecimal value represented with lowercase characters (unsigned integer type)
+
*''%u'' -> Número natural (unsigned integer type).
*''%X'' -> Hexadecimal value represented with uppercase characters (unsigned integer type)
+
*''%x'' -> Valor hexadecimal representado en minúsculas (unsigned integer type)
*''%o'' -> Octal value (unsigned integer type)
+
*''%X'' -> Valor hexadecimal representado en mayúsculas(unsigned integer type)
*''%f'' -> Rational number (number with a floating point) with the normal (showing all numbers) notation (both float and double types)
+
*''%o'' -> Valor octal (unsigned integer type)
*''%e'' -> Rational number (number with a floating point) with exponential notation using lowercase ''e'' (both float and double types)
+
*''%f'' -> Número racional (con decimales) with the normal (showing all numbers) notation (tipos float y double)
*''%E'' -> Rational number (number with a floating point) with exponential notation using uppercase ''E'' (both float and double types)
+
*''%e'' -> Número racional (number with a floating point) con valor exponencial representado a partir de ''e'' minúscula (tipos float y double types)
 +
*''%E'' -> Número racional (number with a floating point) con valor exponencial representado a partir de la ''E'' mayúscula (tipos float y double types)
 
*''%g'' -> Rational number (number with a floating point) with normal or exponential notation depending on the value. If exponential, a lowercase ''e'' will be used  (both float and double types)
 
*''%g'' -> Rational number (number with a floating point) with normal or exponential notation depending on the value. If exponential, a lowercase ''e'' will be used  (both float and double types)
*''%G'' -> Rational number (number with a floating point) with normal or exponential notation depending on the value. If exponential, an uppercase ''E'' will be used  (both float and double types)
+
*''%G'' -> Núnero racional (number with a floating point) with normal or exponential notation depending on the value. If exponential, an uppercase ''E'' will be used  (both float and double types)
*''%c'' -> A single character text representation (integer type)
+
*''%c'' -> Muestra caracteres (tipo integer)
*''%s'' -> A string (array, pointer of integers type)
+
*''%s'' -> Un string (array, pointer of integers type)
*''%p'' -> Displays a memory addess (pointer type)
+
*''%p'' -> Muestra la dirección de memoria (tipo pointer)
*''%n'' -> The variable that is assigned to this format specifier will be given the value of the number of characters displayed up to know (integer type)
+
*''%n'' -> The variable that is assigned to this format specifier will be given the value of the number of characters displayed up to know (tipo integer)
  
 
=== Type extensions ===
 
=== Type extensions ===
  
Sometimes, some characters can be inserted between ''%'' and the character representing the type of data. This insterted characters are meant to extend the information about the type of data the format specifier is going to be substituted with:
+
En algunos casos, algunos caracteres se pueden incluir entre el ''%'' y el carácter que especifica el tipo de dato. Este carácter insertado entre ambos significa el tipo de dato por el que va ser substituido el dato original.:
*''h'' -> Will turn into short integer type. Valid for ''d'', ''i'', ''o'', ''u'', ''x'', ''X'' and ''n''.
+
:
*''l'' -> Will turn into long integer type. Valid for for ''d'', ''i'', ''o'', ''u'', ''x'', ''X'' and ''n''.
+
*''h'' -> Convertirá en short integer type. Válido para ''d'', ''i'', ''o'', ''u'', ''x'', ''X'' y ''n''.
*''L'' -> Will turn into long double type. Valid for 'e'', ''E'', ''f'', ''F'', ''g'', ''G''
+
*''l'' -> Convertirá en long integer type. Válido para ''d'', ''i'', ''o'', ''u'', ''x'', ''X'' y ''n''.
 +
*''L'' -> Convertirá en long double type. Válido para  ''e'', ''E'', ''f'', ''F'', ''g'', ''G''
  
=== Output tweaks ===
+
=== Trucos  ===
  
Also, some of the format specifiers allow to tweak a bt how they should be outputted. This tweaking codes must be inserted between ''%'' and the type character:
+
 
*''-'' -> Aligns to the left
+
Además, algunos de los códigos de formato permiten realizar ciertas modificaciones a la hora de cambiar el aspecto de salida. Estos códigos deben ser insertados entre el ''%'' y el caracter:
*''+'' -> Prints plus ( ''+'' ) sign even when the number is positive. Valid for *''d'', ''i'', ''e'', ''E'', ''f'', ''g'' and ''G''.
+
*''-'' -> Alinea a la izquierda
*''0'' -> Fill the blank spaces with zeros ( ''0'' ) instead of spaces. Valid for *''d'', ''i'', ''u'', ''x'', ''X'', ''o'', ''e'', ''E'', ''f'', ''g'' and ''G''.
+
*''+'' -> Muestra un símbolo ( ''+'' ) cuando el número es positivo. Válido para  *''d'', ''i'', ''e'', ''E'', ''f'', ''g'' y ''G''.
*''#'' -> It will act in different ways depending on the type of data:
+
*''0'' -> Rellena los espacios en blanco con ceros ( ''0'' ). Válido para *''d'', ''i'', ''u'', ''x'', ''X'', ''o'', ''e'', ''E'', ''f'', ''g'' y ''G''.
**''o': A zero ( ''0'' ) will be prepended when the data is non-zero.
+
*''#'' -> Actuará de diversos modos dependiendo del tipo de datos.
**''x'' and ''X'': Prepends ''0x'' or ''0X'' to the data, depending whether the format specifier was ''x'' or ''X''.
+
**''o': Un cero ( ''0'' ) will be prepended when the data is non-zero.
**''f'', ''e'', ''E'', ''g'' and ''G'': Displays the decimal point even when the data is an integer (no decimals).
+
**''x'' y ''X'': Prepends ''0x'' or ''0X'' to the data, depending whether the format specifier was ''x'' or ''X''.
**''g'' and ''G'': The trailing zeros are not removed.
+
**''f'', ''e'', ''E'', ''g'' y ''G'': Muestra la coma decimal incluso cuando el número no es decimal..
 +
**''g'' y ''G'': The trailing zeros are not removed.
 
*''<non-zero decimal value>'' -> Specifies the minimum width the data must occupy (if not all is occupied, it will be padded). Can be used together with ''0''.
 
*''<non-zero decimal value>'' -> Specifies the minimum width the data must occupy (if not all is occupied, it will be padded). Can be used together with ''0''.
 
*''.<decimal value>'' -> It will act in different ways depending on the type of data:
 
*''.<decimal value>'' -> It will act in different ways depending on the type of data:
Line 106: Line 112:
 
*''%%'' -> This is not a format specifier, instead, it is only meant to be used to avoid ambiguousity. It will display a single ''%'' character.
 
*''%%'' -> This is not a format specifier, instead, it is only meant to be used to avoid ambiguousity. It will display a single ''%'' character.
  
=== Important note ===
+
=== Nota importante ===
 +
 
  
You may '''NEVER''' change the order of the format specifiers, it would lead to undesired events! They must be in the same order in the translation, as they were in the original string.
+
'''NUNCA''' debes cambiar el orden de los códigos de formateo, causaría efectos inesperados. Deben ir en el mismo orden que en original mientras  realices la traducción.
 +
Ejemplo: En el caso de que tradujeras la frase  ''"I am %d years old and my name is %s."'' a ''"Mi nombre es  %s y tengo %d años."'' (ten en cuenta ''%s'' and ''%d'' han cambiado de orden), esto causaría un error fatal del [[aMule]] cuando intentara mostrar la frase..  
  
Example: If you'd translate the string ''"I am %d years old and my name is %s."'' to ''"Meine name ist %s und ich bin %d Jahre alt."'' (notice that ''%s'' and ''%d'' are swapped), would probably cause [[aMule]] to crash when trying to display this string.
+
=== Ejemplo  ===
  
=== Examples ===
+
A continuación se muestran una serie de ejemplos de los codigos de formateo que vimos anteriormente. Se muestran en parejas incluyendo la línea de código y la salida que tendrá dicha línea de código en el sistema.. En otras palabras, la primera línea representa el código  [http://www.icce.rug.nl/documents/cplusplus C++] y la segunda línea  (o grupo de línea en el caso de que sea necesario explicarlo en más de una línea) explica como el código  [http://www.icce.rug.nl/documents/cplusplus C++] de la línea anterior se ejecuta en el sistema, Los datos por los que los códigos de formateo son substituidos son aleatorios.  (bueno, no exactamente aleatorios, he incluido datos con significado en cada ejemplo):
  
The following are some examples for the above format specifiers. They are listed as couples of code-line + output. So, the first line represents the line in the way it is written into the [http://www.icce.rug.nl/documents/cplusplus C++] code and the second line (or group of lines if it needs more than one line) represents. The data for which the format specifiers are being substituted is random (well, not really random, I've just set something meaning-full in each example):
 
  
**Code line: ''"I am %s and I am %d years old."''
+
**Línea de código: ''"I am %s and I am %d years old."''
**Output: ''I am [[User:Jacobo221|Jacobo221]] and I am 19 years old.''
+
**Salida: ''I am [[User:Jacobo221|Jacobo221]] and I am 19 years old.''
  
**Code line: ''"The first letter in the english alphabet is %c"''
+
**Línea de código: ''"The first letter in the english alphabet is %c"''
**Output: ''The first letter in the english alphabet is A''
+
**Salida: ''The first letter in the english alphabet is A''
  
**Code line: ''"There exists a format specifier which is %%%c"''
+
**Línea de código: ''"There exists a format specifier which is %%%c"''
**Output: ''There exists a format specifier which is %E''
+
**Salida: ''There exists a format specifier which is %E''
  
**Code line: ''"There exists a format specifier which is %%c"''
+
**Línea de código: ''"There exists a format specifier which is %%c"''
**Output: ''There exists a format specifier which is %c''
+
** Salida: ''There exists a format specifier which is %c''
  
**Code line: ''"%E and %e are the same number"''
+
**Línea de código: ''"%E and %e are the same number"''
**Output: ''9.186329E+00 and 9.186329e+00 are the same number''
+
** Salida: ''9.186329E+00 and 9.186329e+00 are the same number''
  
**Code line: ''"%g is in normal notation while %g is in exponential notation"''
+
**Línea de código: ''"%g is in normal notation while %g is in exponential notation"''
**Output: ''0.25 is in normal notation while 3.234234E+34 is in exponential notation''
+
**Salida: ''0.25 is in normal notation while 3.234234E+34 is in exponential notation''
  
**Code line: ''"%+d is a positive number"''
+
**Línea de código: ''"%+d is a positive number"''
**Output: ''+5 is a positive number''
+
**Salida: ''+5 is a positive number''
  
**Code line: ''"%05f says: Am I not 0-plenty?"''
+
**Línea de código: ''"%05f says: Am I not 0-plenty?"''
**Output: ''000.250000 says: Am I not 0-plenty?''
+
** Salida: ''000.250000 says: Am I not 0-plenty?''
  
**Code line: ''"Both %#o and %#X start with notation specifier"''
+
**Línea de código: ''"Both %#o and %#X start with notation specifier"''
**Output: ''Both 0345 and 0X65FC start with notation specifier''
+
**Salida: ''Both 0345 and 0X65FC start with notation specifier''
  
**Codeline: ''"%010x must be plenty of zeros"''
+
**Línea de código: ''"%010x must be plenty of zeros"''
**Output: ''00000065fc must be plenty of zeros''
+
**Salida: ''00000065fc must be plenty of zeros''
  
**Codeline: ''"Pi number is %.2f"''
+
**Línea de código: ''"Pi number is %.2f"''
**Output: ''Pi number is 3.14''
+
**Salida: ''Pi number is 3.14''
  
**Codeline: ''"Look what happens when you read the four letters in [http://www.mozilla.org/products/firefox Firefox]: %.4s"''
+
** Línea de código: ''"Look what happens when you read the four letters in [http://www.mozilla.org/products/firefox Firefox]: %.4s"''
**Output: ''Look what happens when you read the four letters in [http://www.mozilla.org/products/firefox Firefox]: Fire''
+
**Salida: ''Look what happens when you read the four letters in [http://www.mozilla.org/products/firefox Firefox]: Fire''
  
== Other stuff ==
+
== Otras herramientas ==
  
There are other things you must have in mind when translating. So keep on reading.
+
También hay otra serie de cosas que debes tener en cuenta cuando realices una traducción, así que lo mejor es que continúes leyendo este documento.
  
 
=== Character cases ===
 
=== Character cases ===

Latest revision as of 13:54, 24 September 2008

MEN AT WORK, PLEASE DONT LINK IT, I WILL LINK IT WHEN FINISHED, THANX ;) fdo. crax

English | Español


Introducción

aMule se realiza en el lenguaje de programación C++. Este lenguaje permite gestionar de una manera sencilla los caracteres pero en algunos casos es necesario recurrir a algún que otro truco.

En el caso de que estés realizando una traducción de aMule, lo mas probable es que te encuentres una series de “cosas extrañas”. Algunas veces serán simplemente tipos de letra, pero en otras ocasiones, éstas se incluyen con un propósito determinado.

Este documento es necesario y obligado para alguien que desea o esta traduciendo el aMule. En este documento se describen todos casos de grupos de caracteres que nunca deben modificarse.

Por la tanto en este documento puedes encontrar la descripción de los grupos de caracteres que no debes modificar y cual es la explicación de cada uno de ellos..

Códigos especiales

Códigos especiales ASCII no representables

Son códigos que representan caracteres en código ASCII los cuales no pueden ser escritos con el teclado.

  • \a -> Normalmente produce una alerta sonora (en algún caso visual) como un pitido
  • \b -> Regresa hacia atrás un caracter
  • \f -> En la mayoría de los sistemas realiza una limpieza de la pantalla.
  • \n -> Finaliza la línea actual y comienza una nueva, situando el cursor al inicio de la nueva línea.
  • \r -> Va al inicio de la línea actual
  • \t -> Tabulación horizontal.
  • \v -> Tabulación vertical.
  • \<octal digits> -> Mostrará octal digits en octal
  • \x<hex digits> -> Mostrará el valor hex digits en hexadecimal

Códigos especiales de desambiguación

Los siguientes no son caracteres que no se puedan escribir mediante el teclado, pero debido a las limitaciones en el lenguaje de programación C++ son necesarios para utilizarlos como:

  • \? -> muestra un signo de interrogación ( ? ) para evitar traducciones tipográficas (no todos los compiladores soportan la traducción tipográfica, por lo que no siempre es necesario)
  • \\ -> Muestra un slash ( \ )
  • \' -> Muestra una comilla simple ( ' )
  • \" -> Muestra comillas ( " )

Ejemplos

A continuación tenemos unos ejemplos de los códigos mostrados anteriormente. Se muestran en parejas incluyendo la línea de código y la salida que tendrá dicha línea de código en el sistema.. En otras palabras, la primera línea representa el código C++ y la segunda línea (o grupo de línea en el caso de que sea necesario explicarlo en más de una línea) explica como el código C++ de la línea anterior se ejecuta en el sistema:

    • Línea de código: "Jacobo221 is an angel\aOh, true, I am not."
    • Salida: Jacobo221 is an angelOh, true, I am not (Se escuchará un pitido justo después de la palabra angel y la siguiente palabra no (Oh) no se mostrará hasta que no finalice el pitido)
    • Línea de código: "I have 6\b5 fingers in my right hand"
    • Salida: I have 5 fingers in my right hand
    • Línea de código: "Where is the <RETURN> key???\nAh, here it is!"
    • Salida: Where is the <RETURN> key???
      Ah, here it is!
    • Línea de código: "I am a BIG lier\rI'm married with Marilyn Monroe"
    • Salida: I'm married with Marilyn Monroe
    • Línea de código: "\141\115\165\x6C\x65"
    • Salida: aMule (Ten en cuenta que el valor en octal de a en código ASCII es 141, el valor en octal M es 115, el valor en octal de u es 165, el valor en hexadecimal del es 6C y por último el valor hexadecimal de e es 65)
    • Línea de código: "Isn\'t it complicated to use the \" and \\ characters\?"
    • Salida: Isn't it complicated to use the " and \ characters?

Códigos de formateo

Códigos de formateo básico

Los códigos de formateo son grupos de caracteres que serán sustituidos por otros datos. El código de formato mismo especifica por que tipo de datos será sustituido:

  • %d -> Valor decimal (signed integer type). Equivalente a %i
  • %i -> Valor decimal (signed integer type). Equivalente a %d
  • %u -> Número natural (unsigned integer type).
  • %x -> Valor hexadecimal representado en minúsculas (unsigned integer type)
  • %X -> Valor hexadecimal representado en mayúsculas(unsigned integer type)
  • %o -> Valor octal (unsigned integer type)
  • %f -> Número racional (con decimales) with the normal (showing all numbers) notation (tipos float y double)
  • %e -> Número racional (number with a floating point) con valor exponencial representado a partir de e minúscula (tipos float y double types)
  • %E -> Número racional (number with a floating point) con valor exponencial representado a partir de la E mayúscula (tipos float y double types)
  • %g -> Rational number (number with a floating point) with normal or exponential notation depending on the value. If exponential, a lowercase e will be used (both float and double types)
  • %G -> Núnero racional (number with a floating point) with normal or exponential notation depending on the value. If exponential, an uppercase E will be used (both float and double types)
  • %c -> Muestra caracteres (tipo integer)
  • %s -> Un string (array, pointer of integers type)
  • %p -> Muestra la dirección de memoria (tipo pointer)
  • %n -> The variable that is assigned to this format specifier will be given the value of the number of characters displayed up to know (tipo integer)

Type extensions

En algunos casos, algunos caracteres se pueden incluir entre el % y el carácter que especifica el tipo de dato. Este carácter insertado entre ambos significa el tipo de dato por el que va ser substituido el dato original.:

  • h -> Convertirá en short integer type. Válido para d, i, o, u, x, X y n.
  • l -> Convertirá en long integer type. Válido para d, i, o, u, x, X y n.
  • L -> Convertirá en long double type. Válido para e, E, f, F, g, G

Trucos

Además, algunos de los códigos de formato permiten realizar ciertas modificaciones a la hora de cambiar el aspecto de salida. Estos códigos deben ser insertados entre el % y el caracter:

  • - -> Alinea a la izquierda
  • + -> Muestra un símbolo ( + ) cuando el número es positivo. Válido para *d, i, e, E, f, g y G.
  • 0 -> Rellena los espacios en blanco con ceros ( 0 ). Válido para *d, i, u, x, X, o, e, E, f, g y G.
  • # -> Actuará de diversos modos dependiendo del tipo de datos.
    • o': Un cero ( 0 ) will be prepended when the data is non-zero.
    • x y X: Prepends 0x or 0X to the data, depending whether the format specifier was x or X.
    • f, e, E, g y G: Muestra la coma decimal incluso cuando el número no es decimal..
    • g y G: The trailing zeros are not removed.
  • <non-zero decimal value> -> Specifies the minimum width the data must occupy (if not all is occupied, it will be padded). Can be used together with 0.
  • .<decimal value> -> It will act in different ways depending on the type of data:
    • f, e and E: Specify the amount of decimals it is allowed to display (if .0, no decimals will be displayed).
    • s: Maximum amount of characters to display (if .0, no characters will be displayed).
  • %% -> This is not a format specifier, instead, it is only meant to be used to avoid ambiguousity. It will display a single % character.

Nota importante

NUNCA debes cambiar el orden de los códigos de formateo, causaría efectos inesperados. Deben ir en el mismo orden que en original mientras realices la traducción. Ejemplo: En el caso de que tradujeras la frase "I am %d years old and my name is %s." a "Mi nombre es  %s y tengo %d años." (ten en cuenta %s and %d han cambiado de orden), esto causaría un error fatal del aMule cuando intentara mostrar la frase..

Ejemplo

A continuación se muestran una serie de ejemplos de los codigos de formateo que vimos anteriormente. Se muestran en parejas incluyendo la línea de código y la salida que tendrá dicha línea de código en el sistema.. En otras palabras, la primera línea representa el código C++ y la segunda línea (o grupo de línea en el caso de que sea necesario explicarlo en más de una línea) explica como el código C++ de la línea anterior se ejecuta en el sistema, Los datos por los que los códigos de formateo son substituidos son aleatorios. (bueno, no exactamente aleatorios, he incluido datos con significado en cada ejemplo):


    • Línea de código: "I am %s and I am %d years old."
    • Salida: I am Jacobo221 and I am 19 years old.
    • Línea de código: "The first letter in the english alphabet is %c"
    • Salida: The first letter in the english alphabet is A
    • Línea de código: "There exists a format specifier which is %%%c"
    • Salida: There exists a format specifier which is %E
    • Línea de código: "There exists a format specifier which is %%c"
    • Salida: There exists a format specifier which is %c
    • Línea de código: "%E and %e are the same number"
    • Salida: 9.186329E+00 and 9.186329e+00 are the same number
    • Línea de código: "%g is in normal notation while %g is in exponential notation"
    • Salida: 0.25 is in normal notation while 3.234234E+34 is in exponential notation
    • Línea de código: "%+d is a positive number"
    • Salida: +5 is a positive number
    • Línea de código: "%05f says: Am I not 0-plenty?"
    • Salida: 000.250000 says: Am I not 0-plenty?
    • Línea de código: "Both %#o and %#X start with notation specifier"
    • Salida: Both 0345 and 0X65FC start with notation specifier
    • Línea de código: "%010x must be plenty of zeros"
    • Salida: 00000065fc must be plenty of zeros
    • Línea de código: "Pi number is %.2f"
    • Salida: Pi number is 3.14
    • Línea de código: "Look what happens when you read the four letters in Firefox: %.4s"
    • Salida: Look what happens when you read the four letters in Firefox: Fire

Otras herramientas

También hay otra serie de cosas que debes tener en cuenta cuando realices una traducción, así que lo mejor es que continúes leyendo este documento.

Character cases

The C++ programming language doesn't consider uppercase and lowercase letters as the same lettes. So, 'a' is a different letter from 'A' for C++ programs. In most cases, this will be insignificant for you, but when dealing with escape codes and format specifiers it does, so please remain them the same.

Leading and ending blank spaces

You will sometimes find strings with either begin or end with a space. This is not a typo. That space is there for a reason. Most usually this reason is one of the following:

  1. Appearance. Maybe it separates the string from somewhere that, without this separation, would look ugly.
  2. Future additions. In 99% of the cases, it will be because some data is going to be appended to it. Imagine you find a string like I am . Although no %s format specifier is found there, some data is going to be added later anyway. So, if the blank space wasn't kept, once translated, in the app it would look like I amme instead of I am me.

Examples

The following are examples of the above cases explained. They are unified into groups of four lines. The first line shows an original string, the second one how it should be translated (the examples are translated into spanish),the third one a possible output and the fourth line translates the translated possible output back into english so that you can understand it in case you don't speak spanish:

    • Code line: "aMule version "
    • Translation: "aMule versión "
    • Output: aMule versión 2.0.0
    • Output (in english): aMule version 2.0.0
    • Code line: " can become a %s aMule user"
    • Translation: " puede llegar a ser un %s usuario de aMule"
    • Output: Cualquiera puede llegar a ser un feliz usuario de aMule
    • Output (in english): Anyone can become a happy aMule user
    • Code line: " this line looks complete and the leading and ending spaces can be deleted because they seem typos "
    • Translation: " esta frase parece completa y los espacios del principio y del final se pueden eliminar porque deben ser un error "
    • Output: Aunque esta frase parece completa y los espacios del principio y del final se pueden eliminar porque deben ser un error no lo es porque, como se puede ver, quedaban cosas por añadir, lo cual demuestra que nunca se deben eliminar esos espacios
    • Output (in english): Allthough this line looks complete and the leading and ending spaces can be deleted because they seem typos it is not because, as you can see, there were still words to be added, so this shows you why you should never delete those spaces

Overall example

Example:

Untranslated:
msgid="I am %s and I a %d-year old\nand I\'m a happy \"aMule\" user "
msgstr=""
Would become (translation to spanish):
msgid="I am %s, %d years old\nand &I\'m a happy \"rabitty-aMule\" user "
msgstr="Soy %s y tengo %d años\ny soy un fel&iz usuario del \"conejillo-aMule\" "
Explanation:
  1. %s and %d must be copied literally since they will be substituted in the program with some string or number. General rule: anything between a character % and the next letter-character (that is, a, b, 'c, etc...) or percentage character (%) must be copied literally.
  2. \n must be copied literally too since it brakes the line into a new line. The general rule is: \ and it's very next character (can be \, a, n, t, ,f, ", ', etc) must be copied literally.
  3. & must be placed 'before the very same letter in the translation since it indicates the combination ALT+letter that will select that option.
  4. The ending space is left since in the original message it was there. Never remove startng or ending spaces, even if they look ugly. They are there for some reason. Nomally this will be because either before or after that string comes another string. For example: "Opening file " has a blank space at the end, so you can expect that right after it the name of a file will be displayed. Something like Opening file server.met