Integración con Weblate

Fundamentos de Weblate

Estructura de los proyectos y los componentes

In Weblate translations are organized into projects and components. Each project can contain number of components and those contain translations into individual languages. The component corresponds to one translatable file (for example GNU gettext PO (Portable Object) or Recursos de cadenas de Android). The projects are there to help you organize component into logical sets (for example to group all translations used within one application).

Additionally, components within projects can be structured using categories. Components can belong to a category, and categories can be nested.

Internally, each project has translations to common strings propagated across other components within it by default. This lightens the burden of repetitive and multi version translation. The translation propagation can be disabled per Configuración de componentes using Permitir propagación de traducciones in case the translations should diverge.

Repository integration

Weblate is built to integrate with upstream version control repository, Localización continua describes building blocks and how the changes flow between them.

Ver también

Architecture overview describes how Weblate works internally.

Atribución al usuario

Weblate mantiene las traducciones correctamente realizadas por los traductores en el repositorio de control de las versiones utilizando el nombre y el correo electrónico. Tener un correo electrónico real adjunto al commit sigue el control de las versiones y permite a servicios como GitHub asociar tus contribuciones hechas en Weblate con tu perfil de GitHub.

This feature also brings in risk of misusing e-mail published in the version control commits. Moreover, once such a commit is published on public hosting (such as GitHub), there is effectively no way to redact it. Weblate allows choosing a private commit e-mail in Cuenta to avoid this.

Therefore, admins should consider this while configuring Weblate:

  • Such a usage of e-mail should be clearly described in service terms in case such document is needed. Información legal can help with that.

  • PRIVATE_COMMIT_EMAIL_OPT_IN puede hacer que los correos electrónicos sean privados de forma predeterminada.

Importing a localization project into Weblate

Weblate has been developed with VCS integration in mind as it’s core feature, so the easiest way is to grant Weblate the access to your repository. The import process will guide you through configuring your translations into Weblate components.

Alternatively, you can let Weblate set up a local-only repository containing all the translations without integration.

Recuperar traducciones actualizadas desde Weblate

Weblate stores updated strings in a database and commits them to a local version-control repository. You can add a Weblate repository (when Git exporter is turned on) as an additional remote repository and fetch translation updates from it.

Antes de esto, puede que quiera confirmar cualquier cambio local pendiente hecho en Weblate (vea Consignas diferidas). Esto puede hacerse desde la interfaz de usuario (en la etiqueta Mantenimiento del repositorio), o desde la línea de comandos usando Cliente de Weblate.

Pushing changes can be automated if you grant Weblate push access to your repository and configure URL de envío al repositorio in the Configuración de componentes, see Enviar cambios efectuados en Weblate.

Alternatively, use API REST de Weblate to update translations so that they match the latest version from the upstream in your remote VCS repository.

Recuperar cambios remotos hacia Weblate

Para obtener en Weblate cualquier cadena actualizada recientemente en su repositorio VCS remoto , permita que Weblate la extraiga del repositorio original . Esto se puede lograr en la interfaz de usuario (en el :guilabel:` Mantenimiento del repositorio` ) o desde la línea de comandos usando Cliente de Weblate.

This can be automated by setting a webhook in your repository to trigger Weblate whenever there is a new commit. See Updating repositories for more details.

If not using VCS integration, you can use the UI or API REST de Weblate to update the translations so that they match your codebase.

Añadir cadenas nuevas

If your translation files are stored in a remote VCS together with the code, you most likely have an existing workflow for developers to introduce new strings. Any way of adding strings will be picked up, but consider using Quality gateway for the source strings to avoid introducing errors.

When translation files are separated from the code, the following ways can introduce new strings into Weblate.

  • Manualmente, utilizando Agregar nueva cadena de traducción desde el menú Herramientas en el idioma de origen . Puede elegir entre los botones de opción Singular y Plural dentro del formulario. Seleccione la forma apropiada de la nueva cadena de traducción que se agregará.

  • Mediante programación, usando la API POST /api/translations/(string:project)/(string:component)/(string:language)/units/.

  • Al cargar el archivo fuente como Reemplazar archivo de traducción existente (esto sobrescribe las cadenas existentes, así que asegúrese de que el archivo incluya cadenas antiguas y nuevas) o Agregar nuevas cadenas, consulte Métodos de importación.

Nota

La posibilidad de añadir cadenas en Weblate requiere Gestionar cadenas.

Updating target-language files

For monolingual files (see Localization file formats), Weblate might add new translation strings present in the Archivo de base monolingüe, and not in actual translations. It does not however perform any automatic cleanup of stale strings, as that might have unexpected results. If you still want to do this, please install the Limpieza de archivos de traducción add-on, which handles cleanup according to your requirements.

Weblate tampoco intentará actualizar archivos bilingües cuando cambie la fuente , por lo que si necesita que los archivos po se actualicen desde pot, hágalo usted mismo usando Actualizar cadenas de origen Métodos de importación, o usando el complemento Actualizar archivos PO para que coincidan con POT (msgmerge) .

Consejo

Source string extraction tools, such as xgettext or lupdate, need to be executed outside of Weblate.

Introducing new strings

You can add new strings in Weblate with Gestionar cadenas turned on, but it is usually better to introduce new strings together with the code changes that introduced them.

Monolingual formats need to be configured so that new strings are added to Archivo de base monolingüe. This is typically done by developers, as they write the code. You might want to use a review process of those strings using Quality gateway for the source strings.

Bilingual formats typically extract strings from the source code using some tooling (like xgettext or intltool-update). Follow your localization framework documentation for instructions how to do that. Once the strings are extracted, there might be an additional step needed to update existing translations, see Updating target-language files.

Consejo

Automating string extraction is presently out of scope for Weblate. It typically involves executing untrusted code what makes it more suitable for a generic continuous integration than localization-specific platform.

You might want to integrate this into your continuous integration pipelines to make new strings automatically appear for translation. Such pipeline should also cover Evitar conflictos de fusión.

Managing the local VCS repository

Weblate almacena todas las traducciones en su repositorio de control de versiones subyacente. Se sugiere que esté conectado a uno remoto, pero también es posible una configuración interna. La Mantenimiento del repositorio permite controlar este repositorio.

Consejo

Con Localización continua, cualquier cambio se envía automáticamente desde el repositorio , por lo que generalmente no es necesario administrarlo manualmente.

../_images/component-repository.webp