Commandes de gestion¶
Note
Running management commands under a different user than the one running your webserver can result in files getting wrong permissions, please check Permissions du système de fichiers for more details.
You will find basic management commands (available as ./manage.py
in the Django sources,
or as an extended set in a script called weblate installable atop Weblate).
Invoking management commands¶
As mentioned before, invocation depends on how you installed Weblate.
If using virtualenv for Weblate, you can either specify the full path to weblate, or activate the virtualenv prior to invoking it:
# Direct invocation
~/weblate-env/bin/weblate
# Activating virtualenv adds it to search path
. ~/weblate-env/bin/activate
weblate
If you are using source code directly (either from a tarball or Git checkout), the
management script is ./manage.py
available in the Weblate sources.
To run it:
python ./manage.py list_versions
If you’ve installed Weblate using the pip installer, or by using the ./setup.py
script, the weblate is installed to your path (or virtualenv path),
from where you can use it to control Weblate:
weblate list_versions
For the Docker image, the script is installed like above, and you can run it using docker exec:
docker exec --user weblate <container> weblate list_versions
For docker-compose-plugin the process is similar, you just have to use docker compose exec:
docker compose exec --user weblate weblate weblate list_versions
In case you need to pass it a file, you can temporary add a volume:
docker compose exec --user weblate /tmp:/tmp weblate weblate importusers /tmp/users.json
add_suggestions¶
- weblate add_suggestions <project> <component> <language> <file>¶
Imports a translation from the file to use as a suggestion for the given translation. It skips duplicated translations; only different ones are added.
- --author USER@EXAMPLE.COM¶
E-mail of author for the suggestions. This user has to exist prior to importing (you can create one in the admin interface if needed).
Exemple :
weblate --author michal@cihar.com add_suggestions weblate application cs /tmp/suggestions-cs.po
auto_translate¶
- weblate auto_translate <project> <component> <language>¶
Modifié dans la version 4.6: Ajouter un paramètre pour le mode de traduction.
Performs automatic translation based on other component translations.
- --source PROJECT/COMPONENT¶
Specifies the component to use as source available for translation. If not specified all components in the project are used.
- --user USERNAME¶
Specify username listed as author of the translations. « Anonymous user » is used if not specified.
- --overwrite¶
Whether to overwrite existing translations.
- --inconsistent¶
Whether to overwrite existing translations that are inconsistent (see Incohérence).
- --add¶
Automatically add language if a given translation does not exist.
- --mt MT¶
Use machine translation instead of other components as machine translations.
- --threshold THRESHOLD¶
Similarity threshold for machine translation, defaults to 80.
- --mode MODE¶
Specify translation mode, default is
translate
butfuzzy
orsuggest
can be used.
Exemple :
weblate auto_translate --user nijel --inconsistent --source weblate/application weblate website cs
Voir aussi
celery_queues¶
- weblate celery_queues¶
Displays length of Celery task queues.
checkgit¶
- weblate checkgit <project|project/component>¶
Prints current state of the back-end Git repository.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
commitgit¶
- weblate commitgit <project|project/component>¶
Commits any possible pending changes to the back-end Git repository.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components,
or use --file-format
to filter based on the file format.
commit_pending¶
- weblate commit_pending <project|project/component>¶
Commits pending changes older than a given age.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
- --age HOURS¶
Age in hours for committing. If not specified the value configured in Configuration des composants is used.
Note
This is automatically performed in the background by Weblate, so there no real need to invoke this manually, besides forcing an earlier commit than specified by Configuration des composants.
Voir aussi
cleanuptrans¶
- weblate cleanuptrans¶
Cleans up orphaned checks and translation suggestions. There is normally no need to run this manually, as the cleanups happen automatically in the background.
Voir aussi
cleanup_ssh_keys¶
- weblate cleanup_ssh_keys¶
Ajouté dans la version 4.9.1.
Performs cleanup of stored SSH host keys:
Removes deprecated RSA keys for GitHub which might cause issues connecting to GitHub.
Removes duplicate entries in host keys.
Voir aussi
createadmin¶
- weblate createadmin¶
Creates an admin
account with a random password, unless it is specified.
- --password PASSWORD¶
Provides a password on the command-line, to not generate a random one.
- --no-password¶
Do not set password, this can be useful with –update.
- --username USERNAME¶
Use the given name instead of
admin
.
- --email USER@EXAMPLE.COM¶
Specify the admin e-mail address.
- --name¶
Specify the admin name (visible).
- --update¶
Update the existing user (you can use this to change passwords).
dump_memory¶
- weblate dump_memory¶
Export a JSON file containing Weblate Translation Memory content.
dumpuserdata¶
- weblate dumpuserdata <file.json>¶
Vide les données utilisateur dans un fichier pour une utilisation ultérieure par importuserdata
.
Indication
Cela devient pratique lorsque vous migrez ou fusionnez des instances Weblate.
import_demo¶
- weblate import_demo¶
Ajouté dans la version 4.1.
Creates a demo project with components based on <https://github.com/WeblateOrg/demo>. Make sure the celery tasks are running before running this command.
Ceci peut être utile lors du développement de Weblate.
- --delete¶
Supprime le projet de démonstration existant.
import_json¶
- weblate import_json <json-file>¶
Importation par lot des composants basés sur les données JSON.
La structure du fichier JSON importé correspond d’assez près à l’objet du composant (voir GET /api/components/(string:project)/(string:component)/
). Vous devez inclure les champs name
et filemask
.
- --project PROJECT¶
Indique de où les composants seront importés.
- --main-component COMPONENT¶
Use the given VCS repository from this component for all of them.
- --ignore¶
Ignorer les composants (déjà) importés.
- --update¶
Mettre à jour les composants (déjà) importés.
Exemple de fichier JSON :
[
{
"slug": "po",
"name": "Gettext PO",
"file_format": "po",
"filemask": "po/*.po",
"new_lang": "none"
},
{
"name": "Android",
"filemask": "android/values-*/strings.xml",
"template": "android/values/strings.xml",
"repo": "weblate://test/test",
"file_format": "aresource"
}
]
Voir aussi
import_memory¶
- weblate import_memory <file>¶
Imports a file into the Weblate translation memory.
Supported file formats are TMX, JSON, XLIFF, PO, CSV.
Specifying a source and a target languages might be necessary for formats other than JSON and TMX.
- --language-map LANGMAP¶
Allows mapping languages in the TMX to the Weblate translation memory. The language codes are mapped after normalization usually done by Weblate.
--language-map en_US:en
va par exemple importer toutes les chaînesen_US
en tant queen
.Cela peut être utile dans le cas où les paramètres locaux de votre fichier TMX s’avèrent ne pas correspondre à ce qui est utilisé dans Weblate.
- --source-language SOURCE_LANG¶
Specifies the source language for imported translations. Typically needed for formats where the languages cannot be determined from the file itself.
- --target-language TARGET_LANG¶
Specifies the target language for imported translations. Typically needed for formats where the languages cannot be determined from the file itself.
import_project¶
- weblate import_project <project> <gitrepo> <branch> <filemask>¶
Batch imports components into project based on the file mask. It is based on the Découverte du composant add-on, so you might want to use that instead.
<project> names an existing project, into which the components are to be imported.
The <gitrepo> defines the Git repository URL to use, and <branch> signifies the Git branch. To import additional translation components from an existing Weblate component, use a weblate://<project>/<component> URL for the <gitrepo>.
The <filemask> defines file discovery for the repository. It can be either be made simple using wildcards, or it can use the full power of regular expressions.
The simple matching uses **
for component name and *
for language, for
example: **/*.po
The regular expression has to contain groups named component and language,
for example: (?P<language>[^/]*)/(?P<component>[^-/]*)\.po
.
The import matches existing components based on files and adds the ones that do not exist. It does not change already existing ones.
- --name-template TEMPLATE¶
Personnaliser le nom d’un composant en utilisant la syntaxe du modèle Django.
Par exemple :
Documentation: {{ component }}
- --base-file-template TEMPLATE¶
Personnaliser le fichier de base pour les traductions en une seule langue.
Par exemple :
{{ component }}/res/values/string.xml
- --new-base-template TEMPLATE¶
Personnaliser le fichier de base pour ajouter de nouvelles traductions.
Par exemple :
{{ component }}/ts/en.ts
- --file-format FORMAT¶
Vous pouvez aussi spécifier les formats du fichier à utiliser (voir Localization file formats) ; il est détecté automatiquement par défaut.
- --language-regex REGEX¶
Vous pouvez indiquer un filtrage sur la langue (voir Configuration des composants) avec ce paramètre sous la forme d’une expression régulière valide.
- --main-component¶
Vous pouvez indiquer le composant principal — celui qui contient actuellement le dépôt VCS.
- --license NAME¶
Specify the overall, project or component translation license.
- --license-url URL¶
Indiquer l’URL où se trouve la licence de la traduction.
- --vcs NAME¶
Si vous devez spécifier le système de contrôle de version à utiliser, vous pouvez le faire ici. Git est le système par défaut.
Pour vous donner quelques exemples, essayons d’importer deux projets.
D’abord les traductions du manuel Debian où chaque langue possède un répertoire séparé avec les traductions de chaque chapître :
weblate import_project \
debian-handbook \
https://salsa.debian.org/hertzog/debian-handbook.git \
bullseye/main \
'*/**.po'
Puis l’outil Tanaguru, où le format du fichier doit être spécifié en même temps que le modèle du fichier de base et la manière dont tous les composants et les traductions sont répartis dans un même répertoire :
weblate import_project \
--file-format=properties \
--base-file-template=web-app/tgol-web-app/src/main/resources/i18n/%s-I18N.properties \
tanaguru \
https://github.com/Tanaguru/Tanaguru \
master \
web-app/tgol-web-app/src/main/resources/i18n/**-I18N_*.properties
Exemple plus élaboré de l’analyse syntaxique des noms de fichiers permettant d’obtenir le composant correct ainsi que la langue à partir d’un nom de fichier tel que src/security/Numerous_security_holes_in_0.10.1.de.po
:
weblate import_project \
tails \
git://git.tails.boum.org/tails master \
'wiki/src/security/(?P<component>.*)\.(?P<language>[^.]*)\.po$'
Filtrer uniquement les traductions pour une seule langue :
./manage import_project \
--language-regex '^(cs|sk)$' \
weblate \
https://github.com/WeblateOrg/weblate.git \
'weblate/locale/*/LC_MESSAGES/**.po'
Importer la documentation Sphinx répartie sur plusieurs fichiers :
$ weblate import_project --name-template 'Documentation: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/**.po'
Importer la documentation Sphinx répartie sur plusieurs fichiers et répertoires :
$ weblate import_project --name-template 'Directory 1: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/dir1/**.po'
$ weblate import_project --name-template 'Directory 2: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/dir2/**.po'
Voir aussi
Vous trouverez d’autres exemples plus détaillés dans le chapître Starting with internationalization , mais vous pouvez aussi utiliser import_json
.
import_projectbackup¶
- weblate import_projectbackup <project_name> <project_slug> <username> <filename>¶
Ajouté dans la version 5.10.
Imports Sauvegarde au niveau Projet.
Indication
Usually it is more comfortable to import project when Ajouter des projets et des composant de traduction.
importuserdata¶
- weblate importuserdata <file.json>¶
Importe les données utilisateur à partir d’un fichier créé par dumpuserdata
.
importusers¶
- weblate importusers --check <file.json>¶
Importe les utilisateurs à partir d’un dump JSON de la base de données Django auth_users .
- --check¶
Cette option vous permet simplement de vérifier si un fichier donné peut être importé et rapporte les éventuels conflits concernant les noms d’utilisateur ou les courriels.
Vous pouvez lister tous les utilisateurs de l’installation Django existante en utilisant :
weblate dumpdata auth.User > users.json
install_addon¶
- weblate install_addon --addon ADDON <project|project/component>¶
Installe une greffon sur un ensemble de composants.
- --addon ADDON¶
Nom du greffon à installer. Par exemple
weblate.gettext.customize
.
- --configuration CONFIG¶
JSON encoded configuration of an add-on.
- --update¶
Mettre à jour la configuration existante du module complémentaire.
Vous pouvez soit définir le projet ou le composant dans lequel installer le greffon (par exemple weblate/application
), ou utiliser --all
pour inclure tous les composants existants.
Pour installer Personnaliser la sortie gettext pour tous les composants :
weblate install_addon --addon weblate.gettext.customize --configuration '{"width": -1}' --update --all
Voir aussi
install_machinery¶
Ajouté dans la version 4.18.
- weblate install_machinery --service SERVICE¶
Installe un service de suggestions automatiques global à tout le site.
- --service SERVICE¶
Nome du service à installer. Par exemple
deepl
.
- --configuration CONFIG¶
JSON encoded configuration of a service.
- --update¶
Update the existing service configuration.
Pour installer DeepL :
weblate install_service --service deepl --configuration '{"key": "x", "url": "https://api.deepl.com/v2/"}' --update
Voir aussi
list_languages¶
- weblate list_languages <locale>¶
Liste les langues prises en charge dans le balisage MediaWiki - codes de langue, noms anglais et noms traduits.
Ceci est utilisé pour générer <https://wiki.l10n.cz/Slovn%C3%ADk_s_n%C3%A1zvy_jazyk%C5%AF>.
list_translators¶
- weblate list_translators <project|project/component>¶
Liste les traducteurs en fonction de la langue à laquelle ils ont contribué pour le projet donné :
[French]
Jean Dupont <jean.dupont@example.com>
[English]
John Doe <jd@example.com>
- --language-code¶
Lister les noms par code de langue au lieu du nom de la langue.
Vous pouvez définir soit le projet ou le composant à utiliser (par exemple weblate/application
), ou utiliser --all
pour lister les traducteurs de tous les composants existants.
list_versions¶
- weblate list_versions¶
Lists all Weblate dependencies and their versions.
loadpo¶
- weblate loadpo <project|project/component>¶
Reloads translations from disk (for example in case you have done some updates in the VCS repository).
- --force¶
Force update, even if the files should be up-to-date.
- --lang LANGUAGE¶
Limit processing to a single language.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
Note
You seldom need to invoke this, Weblate will automatically load changed files for every VCS update. This is needed in case you manually changed an underlying Weblate VCS repository or in some special cases following an upgrade.
lock_translation¶
- weblate lock_translation <project|project/component>¶
Prevents further translation of a component.
Indication
Useful in case you want to do some maintenance on the underlying repository.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
Voir aussi
migrate¶
- weblate migrate¶
Migrates database to current Weblate schema. The command line options are
described at Django migrate
.
Indication
In case you want to run an installation non interactively, you can use
weblate migrate --noinput
, and then create an admin user using
createadmin
command.
Voir aussi
move_language¶
- weblate move_language source target¶
Allows you to merge language content. This is useful when updating to a new version which contains aliases for previously unknown languages that have been created with the (generated) suffix. It moves all content from the source language to the target one.
Exemple :
weblate move_language cze cs
After moving the content, you should check whether there is anything left (this is subject to race conditions when somebody updates the repository meanwhile) and remove the (generated) language.
pushgit¶
- weblate pushgit <project|project/component>¶
Pushes committed changes to the upstream VCS repository.
- --force-commit¶
Force commits any pending changes, prior to pushing.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
Note
Weblate pushes changes automatically if Pousser lors du commit in Configuration des composants is turned on, which is the default.
unlock_translation¶
- weblate unlock_translation <project|project/component>¶
Unlocks a given component, making it available for translation.
Indication
Useful in case you want to do some maintenance on the underlying repository.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
Voir aussi
setupgroups¶
- weblate setupgroups¶
Configure les groupes par défaut et ajoute optionnellement tous les utilisateurs à ce groupe.
- --no-privs-update¶
Désactive la mise à jour automatique des groupes existants (ajoute uniquement les nouveaux).
- --no-projects-update¶
Empêche les mises à jour automatiques des groupes pour les projets existants. Cela permet d’ajouter les nouveaux groupes ajoutés aux projets existants, voir Contrôle d’accès au projet.
Voir aussi
setuplang¶
- weblate setuplang¶
Updates list of defined languages in Weblate.
- --no-update¶
Turns off automatic updates of existing languages (only adds new ones).
updatechecks¶
- weblate updatechecks <project|project/component>¶
Updates all checks for all strings.
Indication
Useful for upgrades which do major changes to checks.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
Note
Checks are recalculated regularly by Weblate in the background, the frequency
can be configured via BACKGROUND_TASKS
.
updategit¶
- weblate updategit <project|project/component>¶
Fetches remote VCS repositories and updates the internal cache.
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components.
Note
Usually it is better to configure hooks in the repository to trigger
Déclencheurs de notification, instead of regular triggering the updates by updategit
.