Comprobaciones y correcciones
Correcciones automáticas personalizadas
You can also implement your own automatic fixup in addition to the standard ones and
include them in AUTOFIX_LIST.
Las correcciones automáticas son potentes pero pueden causar daños; tenga cuidado al escribir una.
For example, the following automatic fixup would replace every occurrence of the string
foo in a translation with bar:
#
# Copyright © 2012–2022 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from django.utils.translation import gettext_lazy as _
from weblate.trans.autofixes.base import AutoFix
class ReplaceFooWithBar(AutoFix):
"""Replace foo with bar."""
name = _("Foobar")
def fix_single_target(self, target, source, unit):
if "foo" in target:
return target.replace("foo", "bar"), True
return target, False
To install custom checks, provide a fully-qualified path to the Python class
in the AUTOFIX_LIST, see Custom quality checks, add-ons and auto-fixes.
Personalizar el comportamiento mediante indicadores
You can fine-tune the Weblate behavior by using flags. This can be done on the source string level (see Información adicional sobre las cadenas de origen), or in the Configuración de componentes (Indicadores de traducción). Some file formats also allow to specify flags directly in the format (see Formatos de archivo admitidos).
The flags are comma-separated, the parameters are separated with colon. You can use quotes to include whitespace or special chars in the string. For example:
placeholders:"special:value":"other value", regex:.*
Both single and double quotes are accepted, special characters are being escaped using backslash:
placeholders:"quoted \"string\"":'single \'quoted\''
Here is a list of flags currently accepted:
rst-textTreat a text as an reStructuredText document, affects Traducción no modificada.
dos-eolUses DOS end-of-line markers instead of Unix ones (
\r\ninstead of\n).read-onlyLa cadena es de solo lectura y no debe editarse en Weblate; vea Cadenas de solo lectura.
priority:NPriority of the string. Higher priority strings are presented first for translation. The default priority is 100, the higher priority a string has, the earlier it is offered for translation.
max-length:NLimit the maximal length for a string to N characters, see Longitud máxima de la traducción.
xml-textTreat text as XML document, affects Sintaxis XML and Marcación XML.
font-family:NOMBREDefine font-family for rendering checks, see Gestionar tipos de letra.
font-weight:PESODefine font-weight for rendering checks, see Gestionar tipos de letra.
font-size:TAMAÑODefine font-size for rendering checks, see Gestionar tipos de letra.
font-spacing:ESPACIADODefine letter spacing for rendering checks, see Gestionar tipos de letra.
icu-flags:FLAGSDefine flags for customizing the behavior of the MessageFormat de ICU quality check.
icu-tag-prefix:PREFIXSet a required prefix for XML tags for the MessageFormat de ICU quality check.
placeholders:NOMBRE:NOMBRE2:...Cadenas sustitutivas esperadas en la traducción; vea Sustitutivos.
replacements:FROM:TO:FROM2:TO2...Replacements to perform when checking resulting text parameters (for example in Tamaño máximo de la traducción or Longitud máxima de la traducción). The typical use case for this is to expand placeables to ensure that the text fits even with long values, for example:
replacements:%s:"John Doe".variants:SOURCEMarcar esta cadena como una variante de cadena con origen coincidente. Ver Variantes de cadenas.
regex:REGEXExpresión regular utilizada para relacionar traducciones; vea Expresión regular.
forbiddenIndica una traducción prohibida en un glosario, ver Traducciones prohibidas.
strict-sameHace que «Traducción no modificada» evite la lista de palabras incorporada; vea Traducción no modificada.
check-glossaryActivar el control de calidad No se ajusta al glosario.
angularjs-formatActivar el control de calidad Cadena de interpolación de AngularJS.
c-formatActivar el control de calidad Formato C.
c-sharp-formatActivar el control de calidad Formato C#.
es-formatActivar el control de calidad Literales de plantilla ECMAScript.
i18next-interpolationActivar el control de calidad Interpolación con i18next.
icu-message-formatEnable the MessageFormat de ICU quality check.
java-printf-formatEnable the Formato Java quality check.
java-formatActivar el control de calidad MessageFormat de Java.
javascript-formatActivar el control de calidad Formato JavaScript.
lua-formatActivar el control de calidad Formato Lua.
object-pascal-formatActivar el control de calidad Formato de Object Pascal.
percent-placeholdersActivar el control de calidad Sustitutivos con signo de porcentaje.
perl-formatActivar el control de calidad Formato Perl.
php-formatActivar el control de calidad Formato PHP.
python-brace-formatActivar el control de calidad Formato de llaves de Python.
python-formatActivar el control de calidad Formato Python.
qt-formatActiva el control de calidad Formato Qt.
qt-plural-formatActiva el control de calidad Formato de plurales de Qt.
ruby-formatActiva el control de calidad Formato Ruby.
scheme-formatActiva el control de calidad Formato Scheme.
vue-formatActiva el control de calidad Formato de Vue I18n.
md-textTrata el texto como un documento Markdown. Activa el control de calidad Enlaces de Markdown, Referencias de Markdown, y Sintaxis de Markdown.
case-insensitiveAdjust checks behavior to be case-insensitive. Currently affects only Sustitutivos quality check.
safe-htmlActiva el control de calidad HTML inseguro.
urlLa cadena debe consistir de solo una URL. Activa el control de calidad URL.
ignore-all-checksIgnore all quality checks.
ignore-bbcodeSaltar el control de calidad Marcación BBCode.
ignore-duplicateOmite el control de calidad Palabras consecutivas duplicadas.
ignore-check-glossaryOmite el control de calidad No se ajusta al glosario.
ignore-double-spaceOmite el control de calidad Espacio duplicado.
ignore-angularjs-formatOmite el control de calidad Cadena de interpolación de AngularJS.
ignore-c-formatOmite el control de calidad Formato C.
ignore-c-sharp-formatOmite el control de calidad Formato C#.
ignore-es-formatOmite el control de calidad Literales de plantilla ECMAScript.
ignore-i18next-interpolationOmite el control de calidad Interpolación con i18next.
ignore-icu-message-formatSkip the MessageFormat de ICU quality check.
ignore-java-formatOmite el control de calidad MessageFormat de Java.
ignore-java-printf-formatSkip the Formato Java quality check.
ignore-javascript-formatOmite el control de calidad Formato JavaScript.
ignore-lua-formatSkip the Formato Lua quality check.
ignore-object-pascal-formatSkip the Formato de Object Pascal quality check.
ignore-percent-placeholdersPasa por alto la comprobación de calidad Sustitutivos con signo de porcentaje.
ignore-perl-formatSkip the Formato Perl quality check.
ignore-php-formatSkip the Formato PHP quality check.
ignore-python-brace-formatSkip the Formato de llaves de Python quality check.
ignore-python-formatSkip the Formato Python quality check.
ignore-qt-formatSkip the Formato Qt quality check.
ignore-qt-plural-formatSkip the Formato de plurales de Qt quality check.
ignore-ruby-formatSkip the Formato Ruby quality check.
ignore-scheme-formatSkip the Formato Scheme quality check.
ignore-vue-formatSkip the Formato de Vue I18n quality check.
ignore-translatedSkip the Se había traducido quality check.
ignore-inconsistentSkip the Incoherente quality check.
ignore-kashidaSkip the Kashida utilizado quality check.
ignore-md-linkSkip the Enlaces de Markdown quality check.
ignore-md-reflinkSkip the Referencias de Markdown quality check.
ignore-md-syntaxSkip the Sintaxis de Markdown quality check.
ignore-max-lengthSkip the Longitud máxima de la traducción quality check.
ignore-max-sizeSkip the Tamaño máximo de la traducción quality check.
ignore-escaped-newlineSkip the \n desiguales quality check.
ignore-end-colonSkip the Dos puntos desiguales quality check.
ignore-end-ellipsisSkip the Puntos suspensivos desiguales quality check.
ignore-end-exclamationSkip the Signo de exclamación desigual quality check.
ignore-end-stopSkip the Punto final desigual quality check.
ignore-end-questionSkip the Signo de interrogación desigual quality check.
ignore-end-semicolonSkip the Punto y coma desigual quality check.
ignore-newline-countSkip the Saltos de renglón desiguales quality check.
ignore-pluralsSkip the Faltan plurales quality check.
ignore-placeholdersPasa por alto la comprobación de calidad Sustitutivos.
ignore-punctuation-spacingSkip the Espaciado de puntuación quality check.
ignore-regexSkip the Expresión regular quality check.
ignore-same-pluralsSkip the Mismos plurales quality check.
ignore-begin-newlineSkip the Salto de renglón al inicio quality check.
ignore-begin-spaceSkip the Espacios iniciales quality check.
ignore-end-newlineSkip the Salto de renglón al final quality check.
ignore-end-spaceSkip the Espacio al final quality check.
ignore-sameSkip the Traducción no modificada quality check.
ignore-safe-htmlOmite la comprobación de calidad HTML inseguro.
ignore-urlOmite la comprobación de calidad URL.
ignore-xml-tagsOmite la comprobación de calidad Marcación XML.
ignore-xml-invalidOmite la comprobación de calidad Sintaxis XML.
ignore-zero-width-spaceOmite la comprobación de calidad Espacio de anchura cero.
ignore-ellipsisOmite la comprobación de calidad Puntos suspensivos.
ignore-icu-message-format-syntaxSkip the Sintaxis MessageFormat de ICU quality check.
ignore-long-untranslatedOmite la comprobación de calidad Largamente no traducida.
ignore-multiple-failuresOmite la comprobación de calidad Varias comprobaciones fallidas.
ignore-unnamed-formatOmite la comprobación de calidad:ref:check-unnamed-format.
ignore-optional-pluralOmite la comprobación de calidad No pluralizada.
Nota
Generalmente la regla se denomina ignore-* para cualquier comprobación, usa su identificador, así puedes utilizarlo incluso para tus comprobaciones personalizadas.
Estas flags se entienden tanto en la configuración de Configuración de componentes, por la configuración de la cadena de origen y en el propio archivo de traducción (por ejemplo en GNU gettext).
Forzar comprobaciones
Nuevo en la versión 3.11.
You can configure a list of checks which can not be ignored by setting Comprobaciones obligatorias in Configuración de componentes. Each listed check can not be dismissed in the user interface and any string failing this check is marked as Needs editing (see Estados de traducción).
Gestionar tipos de letra
Nuevo en la versión 3.7.
Consejo
Las fuentes cargadas en Weblate se usan únicamente a efectos de comprobación Tamaño máximo de la traducción, no tienen efecto en la interfaz de usuario de Weblate.
La comprobación Tamaño máximo de la traducción utilizada para calcular las dimensiones del texto renderizado necesita que la fuente se cargue en Weblate y se seleccione mediante una flag de traducción (ver Personalizar el comportamiento mediante indicadores).
La herramienta de gestión de fuentes de Weblate en Fonts bajo el menú Manage de tu proyecto de traducción proporciona una interfaz para cargar y gestionar las fuentes. Se pueden cargar fuentes TrueType u OpenType, configurar grupos de fuentes y utilizarlas en la comprobación.
Los grupos de fuentes permiten definir diferentes fuentes para distintos idiomas, lo que suele ser necesario para los idiomas no latinos:
Los grupos de fuentes se identifican por su nombre, que no puede contener espacios en blanco ni caracteres especiales, para que pueda utilizarse fácilmente en la definición de la comprobación:
El tipo de letra y el estilo se reconocen automáticamente después de cargarlos:
Puedes tener varias fuentes cargadas en Weblate:
Para utilizar las fuentes que comprueban la longitud de la cadena, pásale los indicadores adecuados (ver Personalizar el comportamiento mediante indicadores). Posiblemente necesitarás los siguientes:
max-size:500Defines maximal width in pixels.
font-family:ubuntuDefine el grupo de fuentes a utilizar especificando su identificador.
font-size:22Defines font size in pixels.
Escribir los propios controles
Se han incorporado una amplia gama de controles de calidad, (ver Comprobaciones de calidad), aunque es posible que no cubran todo lo que quieres comprobar. Se puede ajustar la lista de comprobaciones realizadas mediante CHECK_LIST, y también puedes añadir controles personalizados.
Subclase del weblate.checks.Check
Defina algunos atributos.
Implementa el ``check``(si quieres tratar los plurales en tu código) o el método ``check_single``(que lo hace por ti).
He aquí algunos ejemplos:
Para instalar controles personalizados, proporciona una ruta muy clara de clase Python en CHECK_LIST, ver Custom quality checks, add-ons and auto-fixes.
Comprueba que el texto de la traducción no contiene «foo»
Esta es una comprobación bastante simple que se limita a revisar si a la traducción le falta la cadena «tal».
#
# Copyright © 2012–2022 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
"""Simple quality check example."""
from django.utils.translation import gettext_lazy as _
from weblate.checks.base import TargetCheck
class FooCheck(TargetCheck):
# Used as identifier for check, should be unique
# Has to be shorter than 50 characters
check_id = "foo"
# Short name used to display failing check
name = _("Foo check")
# Description for failing check
description = _("Your translation is foo")
# Real check code
def check_single(self, source, target, unit):
return "foo" in target
Comprueba que los plurales del texto traducido al checo son diferentes
Comprobación que utiliza la información de idioma para cerciorarse de que las dos formas de plural en checo no sean iguales.
#
# Copyright © 2012–2022 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
"""Quality check example for Czech plurals."""
from django.utils.translation import gettext_lazy as _
from weblate.checks.base import TargetCheck
class PluralCzechCheck(TargetCheck):
# Used as identifier for check, should be unique
# Has to be shorter than 50 characters
check_id = "foo"
# Short name used to display failing check
name = _("Foo check")
# Description for failing check
description = _("Your translation is foo")
# Real check code
def check_target_unit(self, sources, targets, unit):
if self.is_language(unit, ("cs",)):
return targets[1] == targets[2]
return False
def check_single(self, source, target, unit):
"""We don't check target strings here."""
return False