Integrando com Weblate¶
Básico do Weblate¶
Estrutura de projetos e componentes¶
No Weblate, as traduções são organizadas em projetos e componentes. Cada projeto pode conter vários componentes, os quais contêm traduções para idiomas individuais. O componente corresponde a um arquivo traduzível (por exemplo, GNU gettext PO (Portable Object) ou Recurso de textos do Android). Os projetos estão lá para ajudá-lo a organizar componentes em conjuntos lógicos (por exemplo, para agrupar todas as traduções usadas dentro de um aplicativo).
Additionally, components within projects can be structured using categories. Components can belong to a category, and categories can be nested.
Internamente, cada projeto tem traduções para textos comuns propagados em outros componentes dentro dele por padrão. Isso alivia o fardo da tradução repetitiva e de várias versões. A propagação da tradução pode ser desabilitada por Configuração de componente usando Permitir propagação de tradução caso as traduções devam divergir.
Repository integration¶
Weblate is built to integrate with upstream version control repository, Localização contínua describes building blocks and how the changes flow between them.
Ver também
Visão geral da arquitetura describes how Weblate works internally.
User attribution¶
Weblate keeps the translations properly authored by translators in the version control repository by using name and e-mail. Having a real e-mail attached to the commit follows the distributed version control spirits and allows services like GitHub to associate your contributions done in Weblate with your GitHub profile.
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 Conta 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. Termos jurídicos can help with that.
PRIVATE_COMMIT_EMAIL_OPT_IN
can make e-mails private by default.
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.
Obtendo traduções atualizadas do Weblate¶
Weblate stores updated strings in a database and commits them to a local version-control repository. You can add a Weblate repository (when Exportador git is turned on) as an additional remote repository and fetch translation updates from it.
Prior to this, you might want to commit any pending local changes made in Weblate (see Commits adiados). This can be done from the user interface (in the Repository maintenance), or from the command-line using Weblate Client.
Pushing changes can be automated if you grant Weblate push access to your repository and configure URL de envio do repositório in the Configuração de componente, see Fazendo push das alterações do Weblate.
Alternatively, use API REST do Weblate to update translations so that they match the latest version from the upstream in your remote VCS repository.
Buscando alterações remotas para o Weblate¶
To fetch any strings recently updated in your remote VCS repository into Weblate, allow Weblate to pull from the upstream repository. This can be achieved in the user interface (in the Repository maintenance), or from the command-line using Weblate Client.
This can be automated by setting a webhook in your repository to trigger Weblate whenever there is a new commit. See Atualizando repositórios for more details.
If not using VCS integration, you can use the UI or API REST do Weblate to update the translations so that they match your codebase.
Ver também
Adicionando novos textos¶
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 Rota de qualidade para os textos fonte to avoid introducing errors.
When translation files are separated from the code, the following ways can introduce new strings into Weblate.
Manually, using Add new translation string from Tools menu in the source language. You can choose between the radio buttons Singular and Plural inside the form. Select the appropriate form of the new translation string to be added.
Programaticamente, usando a API
POST /api/translations/(string:project)/(string:component)/(string:language)/units/
.Ao enviar o arquivo fonte como Substituir arquivo tradução existente (isso sobrescreve os textos existentes, portanto, certifique-se de que o arquivo inclua os textos antigos e novos) ou Adicionar novos textos. Veja Métodos de importação.
Nota
The ability to add strings in Weblate requires Gerenciar textos.
Updating target-language files¶
For monolingual files (see Formatos de arquivos suportados), Weblate might add new translation strings present in the Arquivo de idioma da base monolíngue, 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 Limpar arquivos de tradução add-on, which handles cleanup according to your requirements.
Weblate will also not try to update bilingual files when the source changes,
so if you need po
files to be updated from pot
, do it yourself by
using Update source strings Métodos de importação, or by using
the Atualizar arquivos PO para corresponder ao POT (msgmerge) add-on.
Dica
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 Gerenciar textos 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 Arquivo de idioma da base monolíngue. This is typically done by developers, as they write the code. You might want to use a review process of those strings using Rota de qualidade para os textos fonte.
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.
Dica
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 Evitando conflitos de mesclagem.
Managing the local VCS repository¶
Weblate stores all translations in its underlying version control repository. It is suggested to be connected to a remote one, but internal-only setup is also possible. The Repository maintenance allows controlling this repository.
Dica
With Localização contínua, any changes are automatically pushed from the repository, so there is usually no need to manage it manually.