chore(docs): Update translation workflow

Weblate settings are changed to rebase commits onto our master continuously. All
that's needed to pull in translations now is to pull, rather than locking, using
a custom script, and resetting the Weblate repo.

Committing translatable strings is now done on every commit and checked on PR,
so that is no longer part of the import process.

Commits on Weblate are squashed using the "squash git commits" addon. It is
configurable to squash all commits into one and add co-author commit messages,
like we do now. Instead I've set it to just squash commits from a single author
for clearer attribution.
reviewable/pr6489/r1
Anthony Bilinski 2022-02-21 02:30:14 -08:00
parent 7aa8d7178e
commit 4f798e9742
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
3 changed files with 13 additions and 173 deletions

View File

@ -156,29 +156,22 @@ apply the normal rating process.
# Translations from Weblate
Weblate provides an easy way for people to translate qTox. On one hand, it does
require a bit more attention & regular checking whether there are new
translations, on the other, it lessened problems that were happening with
"manual" way of providing translations.
Weblate provides an easy way for people to translate qTox.
New translable strings need to be generated into a form Weblate can consume
using `./tools/update-translation-files.sh ALL` and commiting the result.
using `./tools/update-translation-files.sh ALL` and commiting the result. This
should be done as soon as strings are available since weblate follows our
branch, so is checked for in CI.
To get translations into qTox:
To get translations into qTox, fast-forward merge from
https://hosted.weblate.org/git/tox/qtox/.
1. Go to `https://hosted.weblate.org/projects/tox/qtox/#repository` and lock
the repository for translations.
2. Make sure you have git setup to automatically gpg sign commits.
3. To update translated strings from Weblate, in the root of the qTox
repository execute the script `tools/update-weblate.sh`
4. If a new translation language has been added, update the following files:
- `translations/CMakeLists.txt`
- `src/widget/form/settings/generalform.cpp`
- `translations/README.md`
- `translations/i18n.pri`
- `translations/translations.qrc`
5. After the Pull Request has been merged, `reset` Weblate to master and
unlock it.
If a new translation language has been added, update the following files:
- `translations/CMakeLists.txt`
- `src/widget/form/settings/generalform.cpp`
- `translations/README.md`
- `translations/i18n.pri`
- `translations/translations.qrc`
# Releases
@ -211,6 +204,7 @@ To get translations into qTox:
[`./tools/update-versions.sh`] script, e.g. `./tools/update-versions.sh
1.11.0`
- Update toxcore version number to the latest tag in [`./buildscripts/download/download_toxcore.sh]
- Pull in latest translations from Weblate.
- Update the bootstrap nodelist at `./res/nodes.json` from https://nodes.tox.chat/json.
This can be done by running [`./tools/update-nodes.sh`]
- Generate changelog with `clog`.
@ -259,7 +253,6 @@ helping for a while, ask to be added to the `qTox` organization on GitHub.
[`CONTRIBUTING.md`]: /CONTRIBUTING.md
[`merge-pr.sh`]: /merge-pr.sh
[`test-pr.sh`]: /test-pr.sh
[`./tools/deweblate-translation-file.sh`]: /tools/deweblate-translation-file.sh
[`./tools/create-tarball.sh`]: /tools/create-tarball.sh
[`./tools/update-nodes.sh`]: /tools/update-nodes.sh
[`./tools/update-versions.sh`]: /tools/update-versions.sh

View File

@ -1,73 +0,0 @@
#!/bin/bash
# Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.org>
# Copyright © 2019 by The qTox Project Contributors
#
# This file is part of qTox, a Qt-based graphical interface for Tox.
# qTox is libre 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.
#
# qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>
# Script to run to clean up translations from Weblate.
#
# It detects whether current HEAD commit seems to be a translation from
# Weblate, and if it is, it proceeds to update the translation commit by
# amending it.
#
# Note: the script assumes:
# * there is only 1 translation file modified
# * translation commit strictly adheres to consistent commit naming used
# * script is called from the root of repo
#
# If those assumptions aren't met, the end result won't be what you want.
set -eu -o pipefail
# get title of the last commit
get_commit_title() {
git log --format=format:%s HEAD~1..HEAD
}
# get the whole commit message
get_whole_commit_name() {
git log --format=format:%B HEAD~1..HEAD
}
# bool, whether HEAD commit is a weblate translation
is_webl_tr() {
local re='^feat\(l10n\): update .* translation from Weblate$'
local commit=$(get_commit_title)
[[ $commit =~ $re ]]
}
# get filename of file to be updated
get_filename() {
local raw=( $(git log --raw | egrep '^:[[:digit:]]{6}' | head -n1) )
local re='^translations/.+\.ts$'
[[ ${raw[5]} =~ $re ]] # check if that's actually right, if not, fail here
echo ${raw[5]}
}
# call the other script to update && amend
update() {
local file=$(get_filename)
local commit_msg=$(get_whole_commit_name)
./tools/update-translation-files.sh "$file"
git commit -S --amend -m "$commit_msg" "$file"
}
main() {
is_webl_tr \
&& update
}
main

View File

@ -1,80 +0,0 @@
#!/bin/bash
# Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.org>
# Copyright © 2019 by The qTox Project Contributors
#
# This file is part of qTox, a Qt-based graphical interface for Tox.
# qTox is libre 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.
#
# qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>
# Script to update the translations from Weblate. Works only if there are no
# merge conflicts. Assumes that working dir is a qTox git repo.
#
# Requires a GPG key to sign merge commits.
# usage:
# ./$script
set -e -o pipefail
readonly COMMIT_NAME="chore(l10n): update translations from Weblate
"
source_functions() {
local fns_file="tools/lib/PR_bash.source"
source $fns_file
}
# If there's no qTox Weblate remote, add it
add_remote_weblate() {
local remote_url="https://hosted.weblate.org/git/tox/qtox/"
local remote_name="weblate"
is_remote_present $remote_name \
|| git remote add $remote_name "${remote_url}"
}
do_merge() {
# update commits
git fetch upstream
git fetch weblate
git checkout upstream/master
local COMMIT_MESSAGE=`git shortlog upstream/master..weblate/master`
# squash and merge
git merge --squash --no-edit weblate/master
# update format for adapt to Qt translation format
./tools/deweblate-translation-file.sh ./translations/*.ts || true
# commit
git commit --no-edit -S -m "$COMMIT_NAME" -m "$COMMIT_MESSAGE"
}
main() {
source_functions
add_remote
add_remote_weblate
do_merge
echo "You can now checkout the changes with:"
echo ""
echo " git checkout -b <branch-name>"
echo ""
}
main