mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 10:33:54 -07:00
CI: Add automatic PR creation for source string updates (#4544)
* wording * add pr creation * Update translations.yml * Update translations.yml * update translation workflow * Update CONTRIBUTING.md * Update CONTRIBUTING.md * Update CONTRIBUTING.md * skip ci update * skip ci update * update conditions * remove empty line * typo * tee test * cleanup * pass data between steps * opt for step output over env variable * remove space * create script * wording * fix fork protection, re-add pr run * updates * Update translations.yml * adjust for new source paths * update comment * wording Co-authored-by: ebbit1q <ebbit1q@gmail.com> * wording * reorder * reorder * fix deprecation of set-output * fix version --------- Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
parent
244cb847fb
commit
ca308636c3
7 changed files with 181 additions and 62 deletions
56
.ci/update_translations.sh
Executable file
56
.ci/update_translations.sh
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
|
||||
# ci script to update translation files
|
||||
# usage:
|
||||
# $0 cockatrice/cockatrice_en@source.ts cockatrice/src common
|
||||
# or
|
||||
# FILE="cockatrice/cockatrice_en@source.ts"
|
||||
# DIRS="cockatrice/src common"
|
||||
# $0
|
||||
# note: directories can't contain spaces
|
||||
|
||||
# check parameters
|
||||
if [[ ! $FILE ]]; then
|
||||
FILE="$1"
|
||||
shift
|
||||
fi
|
||||
if [[ ! $FILE ]]; then
|
||||
echo "no output file selected" >&2
|
||||
exit 2;
|
||||
fi
|
||||
if [[ ! $DIRS ]]; then
|
||||
DIRS="$*"
|
||||
fi
|
||||
if [[ ! $DIRS ]]; then
|
||||
echo "no source directories selected to translate" >&2
|
||||
exit 2;
|
||||
fi
|
||||
if [[ ! -e $FILE ]]; then
|
||||
echo "output file does not exist at: $FILE" >&2
|
||||
exit 3;
|
||||
fi
|
||||
|
||||
# print version
|
||||
if ! lupdate -version; then
|
||||
echo "failed to run lupdate" >&2
|
||||
exit 4;
|
||||
fi
|
||||
|
||||
# run lupdate, duplicating the output in stderr and saving it
|
||||
# for convenience we ignore that $DIRS will be split on spaces
|
||||
# shellcheck disable=SC2086
|
||||
if ! got="$(lupdate $DIRS -ts "$FILE" | tee /dev/stderr)"; then
|
||||
echo "failed to update $FILE with $DIRS" >&2
|
||||
exit 4;
|
||||
fi
|
||||
|
||||
# trim output
|
||||
output="${got##*(}" # trim everything before last (
|
||||
output="${output%%)*}" # trim everything after first )
|
||||
if [[ $output == $got ]]; then
|
||||
echo "could not parse generated output" >&2
|
||||
exit 4;
|
||||
fi
|
||||
|
||||
# write output to ci environment file
|
||||
echo "output=$output" >> $GITHUB_OUTPUT
|
||||
11
.ci/update_translations_template.md
Normal file
11
.ci/update_translations_template.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Updated language source strings:
|
||||
- {{ .cockatrice_output }} (Cockatrice)
|
||||
- {{ .oracle_output }} (Oracle)
|
||||
|
||||
<br>
|
||||
|
||||
Last changes are based on commit {{ .commit }}.
|
||||
|
||||
---
|
||||
*This PR is automatically generated and updated by the workflow at `.github/workflows/translations.yml`.*<br>
|
||||
*After merging, all changes to the source language are available for translation at [Transifex](https://www.transifex.com/projects/p/cockatrice/) shortly.*
|
||||
Loading…
Add table
Add a link
Reference in a new issue