Skip to content

While using autosave, the app keeps reopening the folder in explorer. For example Desktop folder. #242

While using autosave, the app keeps reopening the folder in explorer. For example Desktop folder.

While using autosave, the app keeps reopening the folder in explorer. For example Desktop folder. #242

Workflow file for this run

name: Sync translations with Crowdin (two-way)
on:
push:
branches: [ main ]
paths:
- '**/Resources*.resx'
- '.github/workflows/crowdin_sync.yml'
- '.github/.crowdin.yml'
issue_comment:
types: [created]
schedule:
- cron: '47 9 * * SUN'
workflow_dispatch:
env:
# The git branch used for sync with crowdin and for the pull request
BRANCH: crowdin
# crowdin config
CONFIG: '.github/.crowdin.yml'
PROJECT: ${{ secrets.CROWDIN_PROJECT_ID }}
TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
concurrency:
group: ${{ github.workflow }}
jobs:
sync:
name: Sync translations with crowdin
runs-on: ubuntu-24.04
if: |
github.event_name != 'issue_comment' || (
contains(github.event.issue.labels.*.name, 'translation') &&
contains(github.event.comment.body, '/sync')
)
steps:
- name: Install crowdin cli
run: |
wget https://github.com/crowdin/crowdin-cli/releases/download/4.1.2/crowdin-cli.zip --no-verbose
unzip crowdin-cli.zip -d crowdin-cli
cd crowdin-cli/*/
sudo ./install-crowdin-cli.sh
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v3
- name: Install pre-commit
run: |
python3 -m pip install pre-commit
pre-commit install
- name: Setup crowdin branch
run: |
ARGS="--base-path=. --config=$CONFIG --project-id=$PROJECT --token=$TOKEN --no-progress"
REF=$(basename $GITHUB_REF)
crowdin branch add $REF $ARGS
ARGS="--branch=$REF $ARGS"
echo "ARGS=$ARGS" >> $GITHUB_ENV
# Merge changes from git and crowdin and sync back to crowdin
##############################################################
- name: Prepare git branch for merge
run: |
git config user.name "Bot"
git config user.email "<>"
git checkout $BRANCH 2>/dev/null || git checkout -b $BRANCH $GITHUB_REF
- name: Download changes from crowdin
run: |
crowdin download sources $ARGS
LANGUAGES=$(crowdin status translation --plain $ARGS | awk '$2>0 { print "-l" $1 }')
crowdin download $LANGUAGES $ARGS
pre-commit run --all-files || true
git status -s
git diff
git add .
git commit -m "Update from crowdin" || true
- name: Merge and resolve conflicts
run: |
git merge $GITHUB_REF -Xtheirs -v
git diff HEAD~1..
- name: Upload to crowdin
run: |
crowdin upload sources --delete-obsolete $ARGS
crowdin upload translations --import-eq-suggestions $ARGS
# Note: Without the "import-eq-suggestions" switch, new translations that literally match the source string
# would not be uploaded, so a PR would be opened during back-sync to remove these (redundant) translations.
# Create or update the pull request with data from crowdin
###########################################################
- name: Clean git branch
run: |
git checkout -B $BRANCH $GITHUB_REF
git checkout $(basename $GITHUB_REF)
- name: Download from crowdin
run: |
crowdin download sources $ARGS
LANGUAGES=$(crowdin status translation --plain $ARGS | awk '$2>0 { print "-l" $1 }')
crowdin download $LANGUAGES $ARGS
pre-commit run --all-files || true
git status -s
git diff
- name: Collect statistics
run: |
echo 'DIFF<<EOF' >> $GITHUB_ENV
git diff -U9999999 | awk '{
if(/^---/){sub(/.*\//,"");F=$0;A=M=D=0}
if(/<data/){i=1;a=d=0}
if(i){if(/^+/){a++}if(/^-/){d++}}
if(/<\/data/){i=0;M+=a&&d;A+=a&&!d;D+=!a&&d}
if(/<\/root/){MM+=M;AA+=A;DD+=D;O=O sprintf("# %-20s %9s %11s %11s\n",F,A?A" added":"",M?M" updated":"",D?D" deleted":"")}
}END{
if(AA){print"+ "AA" translations added"}
if(MM){print"+ "MM" translations updated"}
if(DD){print"- "DD" translations deleted"}
print O
}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo 'INFO<<EOF' >> $GITHUB_ENV
crowdin status -v $ARGS >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
branch: ${{ env.BRANCH }}
commit-message: Translation updates from Crowdin
author: "Contributing Translators <[email protected]>"
title: Translation updates from Crowdin
labels: |
translation
body: |
Translation updates from [Crowdin project](https://crowdin.com/project/PasteIntoFile)
```diff
${{ env.DIFF }}
```
See [recent activity](https://crowdin.com/project/PasteIntoFile/activity-stream)
<details><summary>Translation info</summary>
```
${{ env.INFO }}
```
</details>
----
- To re-sync and update this PR include /sync in a comment.
- To attribute translators, use squash merge with `Co-authored-by: eltos <[email protected]>`
- *Do not delete the branch after merging! It is required to correctly merge future changes from GitHub and Crowdin without overwriting either.*