Skip to content

Commit

Permalink
Fix translations import script
Browse files Browse the repository at this point in the history
  • Loading branch information
rm3l committed May 27, 2024
1 parent 01c402f commit 2b4fe65
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:

runs-on: ubuntu-latest

permissions:
contents: write

steps:

- uses: actions/checkout@v4
Expand All @@ -38,14 +41,12 @@ jobs:

- name: "Set environmental variables"
run: |
echo "CIRCLE_BUILD_NUM=$GITHUB_RUN_ID/$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
echo "CIRCLE_SHA1=$GITHUB_SHA" >> $GITHUB_ENV
echo "CI_BUILD_NUM=$GITHUB_RUN_ID/$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
echo "CI_SHA1=$GITHUB_SHA" >> $GITHUB_ENV
- name: Import translations from Crowdin if needed
run: ./tools/import-translations-github.sh
env:
# import-translations-github.sh script is currently tied to Travis CI
CIRCLE_PULL_REQUEST: ''
GITHUB_API_KEY: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
Expand Down
91 changes: 45 additions & 46 deletions tools/import-translations-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,57 @@

set -euxo pipefail

if [ "$CIRCLE_PULL_REQUEST" == "" ]; then
echo -e "Starting translation import...\n"

echo -e "Starting translation import...\n"
#go to home and setup git
cd $HOME
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

#go to home and setup git
cd $HOME
git config --global user.email "${GIT_COMMIT_USER_EMAIL:-circle_ci@rm3l.org}"
git config --global user.name "${GIT_COMMIT_USER_NAME:-'Circle CI'}"
git clone --branch=master https://rm3l:$GITHUB_API_KEY@github.com/rm3l/maoni.git master > /dev/null

git clone --branch=master https://rm3l:$GITHUB_API_KEY@github.com/rm3l/maoni.git master > /dev/null
cd master
mkdir -p crowdin-cli-gh
cd crowdin-cli-gh
wget -q https://github.com/crowdin/crowdin-cli/releases/download/3.19.4/crowdin-cli.zip
unzip -qj crowdin-cli.zip
cd ..

cd master
wget -q https://github.com/crowdin/crowdin-cli/releases/download/3.19.4/crowdin-cli.zip
unzip -qj crowdin-cli.zip
# Update sources
java -jar crowdin-cli.jar upload sources
# Download translations
java -jar crowdin-cli.jar download
rm -rf crowdin.bat crowdin-cli.jar crowdin-cli.zip crowdin.sh setup_crowdin.bat
# Update sources
java -jar ./crowdin-cli-gh/crowdin-cli.jar upload sources
# Download translations
java -jar ./crowdin-cli-gh/crowdin-cli.jar download

# import listing graphics
for playLangPath in ./maoni-sample/src/main/play/*-*; do
# Crowdin reformats the 'title' file, which makes it unusable by the Play Publisher Gradle plugin
awk 'BEGIN{f=1} /#X-Generator/{f=0} f{print} $0{f=1}' ${playLangPath}/listing/title > ${playLangPath}/listing/title.tmp
mv ${playLangPath}/listing/title.tmp ${playLangPath}/listing/title
sed -i 's/Maoni=//g' ${playLangPath}/listing/title
for d in featureGraphic icon phoneScreenshots promoGraphic sevenInchScreenshots tenInchScreenshots tvBanner tvScreenshots; do
cp -r ./maoni-sample/src/main/play/en-US/listing/${d} ${playLangPath}/listing/ || true
done
done
rm -rf ./crowdin-cli-gh

#Sanitize, so it compiles with what we have in Google Play Store
rm -rf ./maoni-sample/src/main/play/af && mv ./maoni-sample/src/main/play/af-ZA ./maoni-sample/src/main/play/af
rm -rf ./maoni-sample/src/main/play/ar && mv ./maoni-sample/src/main/play/ar-SA ./maoni-sample/src/main/play/ar
rm -rf ./maoni-sample/src/main/play/ca && mv ./maoni-sample/src/main/play/ca-ES ./maoni-sample/src/main/play/ca
rm -rf ./maoni-sample/src/main/play/ro && mv ./maoni-sample/src/main/play/ro-RO ./maoni-sample/src/main/play/ro
rm -rf ./maoni-sample/src/main/play/sr && mv ./maoni-sample/src/main/play/sr-SP ./maoni-sample/src/main/play/sr
rm -rf ./maoni-sample/src/main/play/uk && mv ./maoni-sample/src/main/play/uk-UA ./maoni-sample/src/main/play/uk
rm -rf ./maoni-sample/src/main/play/vi && mv ./maoni-sample/src/main/play/vi-VN ./maoni-sample/src/main/play/vi
rm -rf ./maoni-sample/src/main/play/{he-IL,af-ZA,ar-SA,ca-ES,ro-RO,sr-SP,uk-UA,vi-VN}
#rm -rf ./maoni-sample/src/main/play/{ar,el-GR,fi-FI,nl-NL,ca,pt-PT,sr,it-IT,fr-FR,ja-JP,ru-RU,no-NO,da-DK,uk,sv-SE,de-DE,pl-PL,cs-CZ,zh-CN,es-ES,vi,zh-TW,hu-HU,tr-TR,pt-BR,af,ro,ko-KR,ar}/whatsnew
# import listing graphics
for playLangPath in ./maoni-sample/src/main/play/*-*; do
# Crowdin reformats the 'title' file, which makes it unusable by the Play Publisher Gradle plugin
awk 'BEGIN{f=1} /#X-Generator/{f=0} f{print} $0{f=1}' ${playLangPath}/listing/title > ${playLangPath}/listing/title.tmp
mv ${playLangPath}/listing/title.tmp ${playLangPath}/listing/title
sed -i 's/Maoni=//g' ${playLangPath}/listing/title
for d in featureGraphic icon phoneScreenshots promoGraphic sevenInchScreenshots tenInchScreenshots tvBanner tvScreenshots; do
cp -r ./maoni-sample/src/main/play/en-US/listing/${d} ${playLangPath}/listing/ || true
done
done

#add, commit and push files
# git add .
# git remote rm origin
# git remote add origin https://rm3l:[email protected]/rm3l/maoni.git
#Sanitize, so it compiles with what we have in Google Play Store
rm -rf ./maoni-sample/src/main/play/af && mv ./maoni-sample/src/main/play/af-ZA ./maoni-sample/src/main/play/af
rm -rf ./maoni-sample/src/main/play/ar && mv ./maoni-sample/src/main/play/ar-SA ./maoni-sample/src/main/play/ar
rm -rf ./maoni-sample/src/main/play/ca && mv ./maoni-sample/src/main/play/ca-ES ./maoni-sample/src/main/play/ca
rm -rf ./maoni-sample/src/main/play/ro && mv ./maoni-sample/src/main/play/ro-RO ./maoni-sample/src/main/play/ro
rm -rf ./maoni-sample/src/main/play/sr && mv ./maoni-sample/src/main/play/sr-SP ./maoni-sample/src/main/play/sr
rm -rf ./maoni-sample/src/main/play/uk && mv ./maoni-sample/src/main/play/uk-UA ./maoni-sample/src/main/play/uk
rm -rf ./maoni-sample/src/main/play/vi && mv ./maoni-sample/src/main/play/vi-VN ./maoni-sample/src/main/play/vi
rm -rf ./maoni-sample/src/main/play/{he-IL,af-ZA,ar-SA,ca-ES,ro-RO,sr-SP,uk-UA,vi-VN}
#rm -rf ./maoni-sample/src/main/play/{ar,el-GR,fi-FI,nl-NL,ca,pt-PT,sr,it-IT,fr-FR,ja-JP,ru-RU,no-NO,da-DK,uk,sv-SE,de-DE,pl-PL,cs-CZ,zh-CN,es-ES,vi,zh-TW,hu-HU,tr-TR,pt-BR,af,ro,ko-KR,ar}/whatsnew

[[ -z $(git status --porcelain) ]] || \
( git add . && \
git commit -m "Automatic translation import (build #$CIRCLE_BUILD_NUM)." -m "Commit $CIRCLE_SHA1" && \
git pull --rebase && \
git push origin master 2>&1 )
[[ -z $(git status --porcelain) ]] || \
( git add . && \
git commit -m "Automatic translation import (build #$CI_BUILD_NUM)" \
-m "Commit $CI_SHA1" \
-m "Co-authored-by: $GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" && \
git pull --rebase && \
git push origin master 2>&1 )

echo -e "... Done with importing translations from Crowdin\n"
fi
echo -e "... Done with importing translations from Crowdin\n"

0 comments on commit 2b4fe65

Please sign in to comment.