mirror of https://github.com/qTox/qTox
chore(tools): add script to automatically update & amend Weblate commits
parent
b798bac064
commit
70246f0208
|
@ -129,30 +129,24 @@ To get translations into qTox:
|
|||
feat(l10n): update $LANGUAGE from Weblate
|
||||
```
|
||||
|
||||
6. Update translation file that was changed to get rid of Weblate's formatting
|
||||
using [`./tools/update-translation-files.sh`], e.g.:
|
||||
6. Get rid of Weblate's formatting and amend the commit using
|
||||
[`./tools/deweblate-translation-file.sh`], i.e.:
|
||||
|
||||
```
|
||||
./tools/update-translation-files.sh en
|
||||
./tools/deweblate-translation-file.sh
|
||||
```
|
||||
|
||||
7. Commit those changes using `--amend`:
|
||||
|
||||
```
|
||||
git commit --amend translations/en.ts
|
||||
```
|
||||
|
||||
8. For translations that haven't yet been cherry-picked repeat steps 4-7.
|
||||
9. Once done with cherry-picking, update all translation files, so that
|
||||
Weblate would get newest strings that changed in qTox:
|
||||
7. For translations that haven't yet been cherry-picked repeat steps 4-6.
|
||||
8. Once done with cherry-picking, update all translation files, so that Weblate
|
||||
would get newest strings that changed in qTox:
|
||||
|
||||
```
|
||||
./tools/update-translation-files.sh ALL
|
||||
```
|
||||
|
||||
10. Once PR with translation gets merged, `Reset` Weblate to current `master`,
|
||||
since without reset there would be a git conflict that would prevent
|
||||
Weblate from getting new strings.
|
||||
9. Once PR with translation gets merged, `Reset` Weblate to current `master`,
|
||||
since without reset there would be a git conflict that would prevent Weblate
|
||||
from getting new strings.
|
||||
|
||||
**It's a good idea to lock translations on Weblate while they're in merge
|
||||
process, so that no translation effort would be lost when resetting Weblate.**
|
||||
|
@ -184,4 +178,4 @@ 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/update-translation-files.sh`]: /tools/update-translation-files.sh
|
||||
[`./tools/deweblate-translation-file.sh`]: /tools/deweblate-translation-file.sh
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.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 <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
|
||||
}
|
||||
|
||||
# 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 | tail -n +7 | 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)
|
||||
./tools/update-translation-files.sh "$file"
|
||||
git commit -S --amend "$file"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
is_webl_tr \
|
||||
&& update
|
||||
}
|
||||
main
|
|
@ -21,7 +21,7 @@
|
|||
# Needed, since Weblate cannot do it automatically.
|
||||
|
||||
# Usage:
|
||||
# ./tools/$script_name [ALL|lang]
|
||||
# ./tools/$script_name [ALL|translation file]
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
|
@ -38,5 +38,5 @@ then
|
|||
git add translations/*.ts
|
||||
git commit -m "$COMMIT_MSG"
|
||||
else
|
||||
$LUPDATE_CMD "translations/$@.ts"
|
||||
$LUPDATE_CMD "$@"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue