1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-23 23:12:09 +01:00

Translate files marked ready but not in Spanish (fixes #299) (#345)

* Translate constants.xml and fix match.xml examples

- constants.xml: full Spanish translation (was entirely in English)
- match.xml: replace French strings in examples with Spanish

Fixes php/doc-es#299 (partially)

* Translate migration80/incompatible.xml to Spanish

* Update printf.xml: sync EN-Revision hash and fix description
This commit is contained in:
Louis-Arnaud
2026-02-27 10:06:45 +01:00
committed by GitHub
parent b39106b0da
commit 1c9ee51944
4 changed files with 653 additions and 633 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,57 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: f4f96ef8b2a95283c92ea2183fe1dedf06f3ad22 Maintainer: julionc Status: ready -->
<!-- Reviewed: yes Maintainer: julionc -->
<!-- EN-Revision: f4f96ef8b2a95283c92ea2183fe1dedf06f3ad22 Maintainer: lacatoire Status: ready -->
<!-- Reviewed: yes -->
<chapter xml:id="language.constants" xmlns="http://docbook.org/ns/docbook">
<title>Constants</title>
<title>Constantes</title>
<simpara>
A constant is an identifier (name) for a simple value. As the name
suggests, that value cannot change during the execution of the
script (except for <link linkend="language.constants.magic">
magic constants</link>, which aren't actually constants).
Constants are case-sensitive. By convention, constant
identifiers are always uppercase.
Una constante es un identificador (nombre) para un valor simple. Como su
nombre sugiere, ese valor no puede cambiar durante la ejecución del
script (excepto las <link linkend="language.constants.magic">
constantes mágicas</link>, que en realidad no son constantes).
Las constantes distinguen entre mayúsculas y minúsculas. Por convención,
los identificadores de constantes se escriben siempre en mayúsculas.
</simpara>
<note>
<para>
Prior to PHP 8.0.0, constants defined using the <function>define</function>
function may be case-insensitive.
Antes de PHP 8.0.0, las constantes definidas con la función
<function>define</function> podían no distinguir entre mayúsculas
y minúsculas.
</para>
</note>
<para>
The name of a constant follows the same rules as any label in PHP. A
valid constant name starts with a letter or underscore, followed
by any number of letters, numbers, or underscores. As a regular
expression, it would be expressed thusly:
El nombre de una constante sigue las mismas reglas que cualquier etiqueta
en PHP. Un nombre de constante válido comienza con una letra o guion bajo,
seguido de cualquier cantidad de letras, números o guiones bajos. Como
expresión regular, se expresaría así:
<code>^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$</code>
</para>
<para>
It is possible to <function>define</function> constants with reserved or even
invalid names, whose value can only be retrieved with the
<function>constant</function> function. However, doing so is not recommended.
Es posible definir constantes con <function>define</function> usando nombres
reservados o incluso inválidos, cuyo valor solo puede obtenerse con la
función <function>constant</function>. Sin embargo, no se recomienda hacerlo.
</para>
&tip.userlandnaming;
<para>
<!-- TODO Move into syntax section? -->
<example>
<title>Valid and invalid constant names</title>
<title>Nombres de constantes válidos e inválidos</title>
<programlisting role="php">
<![CDATA[
<?php
// Valid constant names
// Nombres de constantes válidos
define("FOO", "something");
define("FOO2", "something else");
define("FOO_BAR", "something more");
// Invalid constant names
// Nombres de constantes inválidos
define("2FOO", "something");
// This is valid, but should be avoided:
// PHP may one day provide a magical constant
// that will break your script
// Esto es válido, pero debe evitarse:
// PHP podría algún día proporcionar una constante mágica
// que rompa el script
define("__FOO__", "something");
?>
@@ -61,109 +62,110 @@ define("__FOO__", "something");
</para>
<note>
<simpara>
For our purposes here, a letter is a-z, A-Z, and the ASCII
characters from 128 through 255 (0x80-0xff).
Para estos propósitos, una letra es a-z, A-Z y los caracteres
ASCII del 128 al 255 (0x80-0xff).
</simpara>
</note>
<simpara>
Like &link.superglobals;, the scope of a constant is global.
Constants can be accessed from anywhere in a script without regard to scope.
For more information on scope, read the manual section on
<link linkend="language.variables.scope">variable scope</link>.
Al igual que las &link.superglobals;, el ámbito de una constante es global.
Las constantes pueden ser accedidas desde cualquier lugar del script sin
importar el ámbito. Para más información sobre el ámbito, consulte la
sección del manual sobre
<link linkend="language.variables.scope">ámbito de las variables</link>.
</simpara>
<note>
<simpara>
As of PHP 7.1.0, class constant may declare a visibility of protected
or private, making them only available in the hierarchical scope of the
class in which it is defined.
A partir de PHP 7.1.0, las constantes de clase pueden declarar una
visibilidad protected o private, haciéndolas disponibles únicamente en
el ámbito jerárquico de la clase en la que se definen.
</simpara>
</note>
<sect1 xml:id="language.constants.syntax">
<title>Syntax</title>
<title>Sintaxis</title>
<simpara>
Constants can be defined using the <literal>const</literal> keyword,
or by using the <function>define</function>-function.
While <function>define</function> allows a constant to be
defined to an arbitrary expression, the <literal>const</literal> keyword has
restrictions as outlined in the next paragraph.
Once a constant is defined, it can never be
changed or undefined.
Las constantes pueden definirse usando la palabra clave
<literal>const</literal> o usando la función <function>define</function>.
Mientras que <function>define</function> permite definir una constante
con una expresión arbitraria, la palabra clave <literal>const</literal>
tiene restricciones como se describe en el siguiente párrafo.
Una vez definida, una constante no puede ser modificada ni eliminada.
</simpara>
<simpara>
When using the <literal>const</literal> keyword,
only scalar (<type>bool</type>, <type>int</type>,
<type>float</type> and <type>string</type>) expressions and constant
<type>array</type>s containing only scalar expressions are accepted.
It is possible to define constants as a <type>resource</type>,
but it should be avoided, as it can cause unexpected results.
Al usar la palabra clave <literal>const</literal>, solo se aceptan
expresiones escalares (<type>bool</type>, <type>int</type>,
<type>float</type> y <type>string</type>) y <type>array</type>s
constantes que contengan únicamente expresiones escalares.
Es posible definir constantes como <type>resource</type>,
pero debe evitarse, ya que puede causar resultados inesperados.
</simpara>
<simpara>
The value of a constant is accessed simply by specifying its name.
Unlike variables, a constant is <emphasis>not</emphasis> prepended
with a <literal>$</literal>.
It is also possible to use the <function>constant</function> function to
read a constant's value if the constant's name is obtained dynamically.
Use <function>get_defined_constants</function> to get a list of
all defined constants.
El valor de una constante se obtiene simplemente especificando su nombre.
A diferencia de las variables, una constante <emphasis>no</emphasis>
va precedida de un signo <literal>$</literal>.
También es posible usar la función <function>constant</function> para
leer el valor de una constante si su nombre se obtiene dinámicamente.
Use <function>get_defined_constants</function> para obtener una lista de
todas las constantes definidas.
</simpara>
<note>
<simpara>
Constants and (global) variables are in a different namespace.
This implies that for example &true; and
<varname>$TRUE</varname> are generally different.
Las constantes y las variables (globales) se encuentran en espacios de
nombres diferentes. Esto implica que, por ejemplo, &true; y
<varname>$TRUE</varname> son generalmente diferentes.
</simpara>
</note>
<simpara>
If an undefined constant is used an <classname>Error</classname> is thrown.
Prior to PHP 8.0.0, undefined constants would be interpreted as a bare
word <type>string</type>, i.e. (CONSTANT vs "CONSTANT").
This fallback is deprecated as of PHP 7.2.0, and an error of level
<constant>E_WARNING</constant> is issued when it happens.
Prior to PHP 7.2.0, an error of level
<link linkend="ref.errorfunc">E_NOTICE</link> has been issued instead.
See also the manual entry on why
<link linkend="language.types.array.foo-bar">$foo[bar]</link> is
wrong (unless <literal>bar</literal> is a constant).
This does not apply to <link
linkend="language.namespaces.rules">(fully) qualified constants</link>,
which will always raise a <classname>Error</classname> if undefined.
Si se usa una constante no definida, se lanza un <classname>Error</classname>.
Antes de PHP 8.0.0, las constantes no definidas se interpretaban como una
cadena (<type>string</type>) sin comillas, es decir (CONSTANT vs "CONSTANT").
Este comportamiento está obsoleto desde PHP 7.2.0, y se emite un error de
nivel <constant>E_WARNING</constant> cuando ocurre.
Antes de PHP 7.2.0, se emitía un error de nivel
<link linkend="ref.errorfunc">E_NOTICE</link>.
Consulte también la entrada del manual sobre por qué
<link linkend="language.types.array.foo-bar">$foo[bar]</link> es
incorrecto (a menos que <literal>bar</literal> sea una constante).
Esto no se aplica a las <link
linkend="language.namespaces.rules">constantes (totalmente) cualificadas</link>,
que siempre lanzarán un <classname>Error</classname> si no están definidas.
</simpara>
<note>
<simpara>
To check if a constant is set, use the <function>defined</function> function.
Para comprobar si una constante está definida, use la función
<function>defined</function>.
</simpara>
</note>
<para>
These are the differences between constants and variables:
Estas son las diferencias entre constantes y variables:
<itemizedlist>
<listitem>
<simpara>
Constants do not have a dollar sign (<literal>$</literal>)
before them;
Las constantes no llevan el signo de dólar (<literal>$</literal>)
delante;
</simpara>
</listitem>
<listitem>
<simpara>
Constants may be defined and accessed anywhere without regard
to variable scoping rules;
Las constantes pueden definirse y accederse desde cualquier lugar
sin importar las reglas de ámbito de las variables;
</simpara>
</listitem>
<listitem>
<simpara>
Constants may not be redefined or undefined once they have been
set; and
Las constantes no pueden redefinirse ni eliminarse una vez
establecidas; y
</simpara>
</listitem>
<listitem>
<simpara>
Constants may only evaluate to scalar values or arrays.
Las constantes solo pueden evaluarse a valores escalares o arrays.
</simpara>
</listitem>
</itemizedlist>
@@ -171,14 +173,14 @@ define("__FOO__", "something");
<para>
<example>
<title>Defining Constants</title>
<title>Definición de constantes</title>
<programlisting role="php">
<![CDATA[
<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // Emits an Error: Undefined constant "Constant"
// Prior to PHP 8.0.0, outputs "Constant" and issues a warning.
echo CONSTANT; // muestra "Hello world."
echo Constant; // Lanza un Error: Undefined constant "Constant"
// Antes de PHP 8.0.0, muestra "Constant" y emite una advertencia.
?>
]]>
</programlisting>
@@ -187,29 +189,29 @@ echo Constant; // Emits an Error: Undefined constant "Constant"
<para>
<example>
<title>Defining Constants using the <literal>const</literal> keyword</title>
<title>Definición de constantes usando la palabra clave <literal>const</literal></title>
<programlisting role="php">
<![CDATA[
<?php
// Simple scalar value
// Valor escalar simple
const CONSTANT = 'Hello World';
echo CONSTANT;
// Scalar expression
// Expresión escalar
const ANOTHER_CONST = CONSTANT.'; Goodbye World';
echo ANOTHER_CONST;
const ANIMALS = array('dog', 'cat', 'bird');
echo ANIMALS[1]; // outputs "cat"
echo ANIMALS[1]; // muestra "cat"
// Constant arrays
// Arrays constantes
define('ANIMALS', array(
'dog',
'cat',
'bird'
));
echo ANIMALS[1]; // outputs "cat"
echo ANIMALS[1]; // muestra "cat"
?>
]]>
</programlisting>
@@ -218,12 +220,12 @@ echo ANIMALS[1]; // outputs "cat"
<note>
<para>
As opposed to defining constants using <function>define</function>,
constants defined using the <literal>const</literal> keyword must be
declared at the top-level scope because they are defined at compile-time.
This means that they cannot be declared inside functions, loops,
<literal>if</literal> statements or
<literal>try</literal>/<literal>catch</literal> blocks.
A diferencia de la definición de constantes con <function>define</function>,
las constantes definidas con la palabra clave <literal>const</literal>
deben declararse en el ámbito de nivel superior porque se definen en
tiempo de compilación. Esto significa que no pueden declararse dentro
de funciones, bucles, instrucciones <literal>if</literal> o bloques
<literal>try</literal>/<literal>catch</literal>.
</para>
</note>
@@ -231,38 +233,40 @@ echo ANIMALS[1]; // outputs "cat"
&reftitle.seealso;
<para>
<simplelist>
<member><link linkend="language.oop5.constants">Class Constants</link></member>
<member><link linkend="language.oop5.constants">Constantes de clase</link></member>
</simplelist>
</para>
</sect2>
</sect1>
<sect1 xml:id="language.constants.predefined">
<title>Predefined constants</title>
<title>Constantes predefinidas</title>
<simpara>
PHP provides a large number of <link
linkend="reserved.constants">predefined constants</link> to any script
which it runs. Many of these constants, however, are created by
various extensions, and will only be present when those extensions
are available, either via dynamic loading or because they have
been compiled in.
PHP proporciona un gran número de <link
linkend="reserved.constants">constantes predefinidas</link> a cualquier
script que ejecuta. Muchas de estas constantes, sin embargo, son creadas
por diversas extensiones, y solo estarán presentes cuando esas extensiones
estén disponibles, ya sea mediante carga dinámica o porque se han
compilado con PHP.
</simpara>
</sect1>
<sect1 xml:id="language.constants.magic">
<title>Magic constants</title>
<title>Constantes mágicas</title>
<para>
There are nine magical constants that change depending on
where they are used. For example, the value of
<constant>__LINE__</constant> depends on the line that it's
used on in your script. All these "magical" constants are resolved
at compile time, unlike regular constants, which are resolved at runtime.
These special constants are case-insensitive and are as follows:
Existen varias constantes mágicas que cambian dependiendo de
dónde se utilicen. Por ejemplo, el valor de
<constant>__LINE__</constant> depende de la línea en la que se
use en el script. Todas estas constantes "mágicas" se resuelven
en tiempo de compilación, a diferencia de las constantes regulares,
que se resuelven en tiempo de ejecución.
Estas constantes especiales no distinguen entre mayúsculas y minúsculas
y son las siguientes:
</para>
<para>
<table>
<title>PHP's magic constants</title>
<title>Constantes mágicas de PHP</title>
<tgroup cols="2">
<thead>
<row>
@@ -274,70 +278,72 @@ echo ANIMALS[1]; // outputs "cat"
<row xml:id="constant.line">
<entry><constant>__LINE__</constant></entry>
<entry>
The current line number of the file.
El número de línea actual del archivo.
</entry>
</row>
<row xml:id="constant.file">
<entry><constant>__FILE__</constant></entry>
<entry>
The full path and filename of the file with symlinks resolved. If used inside an include,
the name of the included file is returned.
La ruta completa y el nombre del archivo con los enlaces simbólicos
resueltos. Si se usa dentro de un include, se devuelve el nombre
del archivo incluido.
</entry>
</row>
<row xml:id="constant.dir">
<entry><constant>__DIR__</constant></entry>
<entry>
The directory of the file. If used inside an include,
the directory of the included file is returned. This is equivalent
to <literal>dirname(__FILE__)</literal>. This directory name
does not have a trailing slash unless it is the root directory.
El directorio del archivo. Si se usa dentro de un include,
se devuelve el directorio del archivo incluido. Es equivalente a
<literal>dirname(__FILE__)</literal>. El nombre del directorio
no incluye la barra final a menos que sea el directorio raíz.
</entry>
</row>
<row xml:id="constant.function">
<entry><constant>__FUNCTION__</constant></entry>
<entry>
The function name, or <literal>{closure}</literal> for anonymous functions.
El nombre de la función, o <literal>{closure}</literal> para
las funciones anónimas.
</entry>
</row>
<row xml:id="constant.class">
<entry><constant>__CLASS__</constant></entry>
<entry>
The class name. The class name includes the namespace
it was declared in (e.g. <literal>Foo\Bar</literal>).
When used
in a trait method, __CLASS__ is the name of the class the trait
is used in.
El nombre de la clase. El nombre de la clase incluye el espacio de
nombres en el que fue declarada (p. ej. <literal>Foo\Bar</literal>).
Cuando se usa en un método de trait, <constant>__CLASS__</constant>
es el nombre de la clase en la que se utiliza el trait.
</entry>
</row>
<row xml:id="constant.trait">
<entry><constant>__TRAIT__</constant></entry>
<entry>
The trait name. The trait name includes the namespace
it was declared in (e.g. <literal>Foo\Bar</literal>).
El nombre del trait. El nombre del trait incluye el espacio de
nombres en el que fue declarado (p. ej. <literal>Foo\Bar</literal>).
</entry>
</row>
<row xml:id="constant.method">
<entry><constant>__METHOD__</constant></entry>
<entry>
The class method name.
El nombre del método de la clase.
</entry>
</row>
<row xml:id="constant.property">
<entry><constant>__PROPERTY__</constant></entry>
<entry>
Only valid inside a <link linkend="language.oop5.property-hooks">property hook</link>. It is equal to the name of the property.
Solo es válido dentro de un <link linkend="language.oop5.property-hooks">hook
de propiedad</link>. Es igual al nombre de la propiedad.
</entry>
</row>
<row xml:id="constant.namespace">
<entry><constant>__NAMESPACE__</constant></entry>
<entry>
The name of the current namespace.
El nombre del espacio de nombres actual.
</entry>
</row>
<row xml:id="constant.coloncolonclass">
<entry><constant><replaceable>ClassName</replaceable>::class</constant></entry>
<entry>
The fully qualified class name.
El nombre completo cualificado de la clase.
</entry>
</row>
</tbody>

View File

@@ -63,11 +63,11 @@ string(19) "This food is a cake"
$age = 18;
$output = match (true) {
$age < 2 => "Bébé",
$age < 13 => "Enfant",
$age <= 19 => "Adolescent",
$age >= 40 => "Adulte âgé",
$age > 19 => "Jeune adulte",
$age < 2 => "Bebé",
$age < 13 => "Niño",
$age <= 19 => "Adolescente",
$age >= 40 => "Adulto mayor",
$age > 19 => "Adulto joven",
};
var_dump($output);
@@ -77,7 +77,7 @@ var_dump($output);
&example.outputs;
<screen>
<![CDATA[
string(9) "Adolescent"
string(12) "Adolescente"
]]>
</screen>
</example>
@@ -285,11 +285,11 @@ string(11) "young adult"
<![CDATA[
<?php
$text = 'Bienvenue chez nous';
$text = 'Bienvenidos a nuestra casa';
$result = match (true) {
str_contains($text, 'Welcome'), str_contains($text, 'Hello') => 'en',
str_contains($text, 'Bienvenue'), str_contains($text, 'Bonjour') => 'fr',
str_contains($text, 'Bienvenidos'), str_contains($text, 'Hola') => 'es',
// ...
};
@@ -300,7 +300,7 @@ var_dump($result);
&example.outputs;
<screen>
<![CDATA[
string(2) "fr"
string(2) "es"
]]>
</screen>
</example>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 099842f34289b4cf932863e1f83d0e9a144d3b06 Maintainer: PhilDaiguille Status: ready -->
<!-- EN-Revision: 49999607f48c5e18ef3954a9c6895adbd6aec27a Maintainer: PhilDaiguille Status: ready -->
<!-- Reviewed: yes -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.printf">
<refnamediv>
@@ -16,7 +16,7 @@
<methodparam rep="repeat"><type>mixed</type><parameter>values</parameter></methodparam>
</methodsynopsis>
<simpara>
Muestra una string formateada.
Produce una salida de acuerdo con <parameter>format</parameter>.
</simpara>
</refsect1>