Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-02-19 21:57:41 +0300
committerGitHub <noreply@github.com>2020-02-19 21:57:41 +0300
commit361bc551294d313631a3c61e07ddf65b97e72041 (patch)
treecff575e5b88cda358cf0daae879cd879b3767783 /.github
parent2cb71e181104d99c4fbf1cf9f5b36421b50246ad (diff)
Adds translation updates action (#15541)
Adds an action to create a PR with translation updates once a week (Saturday 2:00 UTC)
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/translations.yml143
1 files changed, 143 insertions, 0 deletions
diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml
new file mode 100644
index 0000000000..2148d2b2d4
--- /dev/null
+++ b/.github/workflows/translations.yml
@@ -0,0 +1,143 @@
+name: Translation Updates
+
+on:
+ schedule:
+ - cron: "0 2 * * 6"
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ services:
+ mysql:
+ image: mysql:5.7
+ env:
+ MYSQL_ALLOW_EMPTY_PASSWORD: true
+ MYSQL_ROOT_PASSWORD: ""
+ MYSQL_DATABASE: piwik_tests
+ ports:
+ - 3306/tcp
+
+
+ steps:
+ - uses: shivammathur/setup-php@v1
+ with:
+ php-version: '7.3'
+ - uses: actions/checkout@v2
+ with:
+ ref: '4.x-dev'
+ lfs: false
+ - name: Prepare branches
+ run: |
+ cat <<- EOF > $HOME/.netrc
+ machine github.com
+ login $GITHUB_ACTOR
+ password $GITHUB_TOKEN
+ machine api.github.com
+ login $GITHUB_ACTOR
+ password $GITHUB_TOKEN
+ EOF
+ chmod 600 $HOME/.netrc
+
+ git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
+ git config --global user.name "$GITHUB_ACTOR"
+
+ git remote add upstream https://github.com/matomo-org/matomo.git
+
+ git push origin --delete translationupdates || true
+ git branch -D translationupdates || true
+ git fetch upstream 4.x-dev
+ git checkout -f upstream/4.x-dev
+ git branch translationupdates
+ git checkout -f translationupdates
+ - name: Checkout submodules
+ run: git submodule update --init --force
+ - name: Install Dependencies
+ run: composer install --prefer-dist
+ - name: Initialize Matomo
+ run: |
+ cp ./tests/travis/config.ini.travis.php ./config/config.ini.php
+ ./console development:enable
+ - name: Sync translations
+ run: ./console translations:update --username ${{ secrets.TransifexUsername }} --password ${{ secrets.TransifexPassword }} --force --no-interaction
+ - name: Check for changes
+ id: changes
+ run: |
+ IFS=$'\n'
+ changes=( $(git diff --numstat | grep -E '([0-9]+)\s+([0-9]+)\s+[a-zA-Z\/]*lang\/([a-z]{2,3}(?:-[a-z]{2,3})?)\.json' ) )
+ unset IFS
+
+ # abort here if no change available
+ if [[ ${#changes[@]} -eq 0 ]]
+ then
+ exit 0
+ fi
+
+ git add lang/
+ git add "*.json"
+
+ declare -i totaladditions=0
+ declare -A additionsByLang
+
+ for (( i=0; i < ${#changes[@]}; i++ )); do
+ line=( ${changes[$i]} )
+ additions=${line[0]}
+
+ if [[ ${line[0]} = "0" ]]
+ then
+ continue;
+ fi
+
+ file=${line[2]}
+ lang=$( echo ${line[2]} | grep -oE '([a-z]{2,3}(?:-[a-z]{2,3})?)\.json' | cut -d'.' -f 1 )
+
+ totaladditions=$(( totaladditions + additions ))
+ additionsByLang[$lang]=$(( additionsByLang[$lang] + additions ))
+ done
+
+ title="Updated $totaladditions strings in ${#additionsByLang[@]} languages (${!additionsByLang[@]})"
+
+ languageInfo=( $( ./console translations:languageinfo ) )
+
+ for i in ${!additionsByLang[@]}; do
+ for j in ${languageInfo[@]}; do
+ if [[ "$j" == "$i|"* ]];
+ then
+ IFS=$'\n'
+ info=( $( echo "$j" | tr "|" "\n" ) )
+ unset IFS
+ break
+ fi
+ done
+
+ message="$message- Updated ${info[1]} (${additionsByLang[$i]} changes / ${info[2]} translated)\n"
+ done
+
+ message="$message\n\nHelp us translate Matomo in your language!\nSignup at https://www.transifex.com/matomo/matomo/\nIf you have any questions, get in touch with us at translations@matomo.org"
+
+ echo $title
+ echo $message
+
+ echo ::set-output name=title::$title
+ echo ::set-output name=message::$message
+ shell: bash
+ - name: Push changes
+ run: |
+ git commit -m "language update"
+ git push --set-upstream origin translationupdates
+ - name: Create PR
+ run: |
+ curl \
+ --request POST \
+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
+ --header 'content-type: application/json' \
+ --data '{
+ "title":"[automatic translation update] ${{ steps.changes.outputs.title }}",
+ "body":"${{ steps.changes.outputs.message }}",
+ "head":"translationupdates",
+ "base":"4.x-dev"
+ }' \
+ --url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls
+ shell: bash
+ if: steps.changes.outputs.title