Skip to content

Commit

Permalink
Support translating Catima app name in feature graphic (#1623)
Browse files Browse the repository at this point in the history
* Support translating Catima app name in feature graphic

Co-authored-by: FC (Fay) Stegerman <[email protected]>
  • Loading branch information
TheLastProject and obfusk authored Nov 11, 2023
1 parent 9e7d51c commit a1011e0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
34 changes: 1 addition & 33 deletions .github/workflows/generate-feature-graphic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,7 @@ jobs:
find .scripts/generate_feature_graphic/fonts -name '*.ttf' -exec cp {} "$HOME/.fonts" \;
fc-cache
- name: Generate featureGraphic.png for each language
run: |
for lang in fastlane/metadata/android/*; do
pushd "$lang"
# Place temporary copy for editing if needed
cp ../../../../.scripts/generate_feature_graphic/featureGraphic.svg featureGraphic.svg
# Extract text after 'Catima - '
export subtext="$(grep -oP '(?<=Catima \S ).*' title.txt || true)"
# If there is subtext, change the .svg accordingly
if [ -n "$subtext" ]; then
perl -pi -e 's/Loyalty Card Wallet/$ENV{subtext}/' featureGraphic.svg
# Set correct font for language if needed (Lexend Deca has limited support)
# We specifically need the Serif version because of the 200 weight
case "$(basename "$lang")" in
bg|el-GR|ru-RU|uk) sed -i "s/Lexend Deca/Noto Serif/" featureGraphic.svg ;;
ja-JP) sed -i "s/Lexend Deca/Noto Serif CJK JP/" featureGraphic.svg ;;
ko) sed -i "s/Lexend Deca/Noto Serif CJK KR/" featureGraphic.svg ;;
zh-CN) sed -i "s/Lexend Deca/Noto Serif CJK SC/" featureGraphic.svg ;;
zh-TW) sed -i "s/Lexend Deca/Noto Serif CJK TC/" featureGraphic.svg ;;
*) ;;
esac
fi
# Ensure images directory exists
mkdir -p images
# Generate .png
convert featureGraphic.svg images/featureGraphic.png
# Optimize .png
optipng images/featureGraphic.png
# Remove metadata (timestamps) from .png
mat2 --inplace images/featureGraphic.png
# Remove temporary .svg
rm featureGraphic.svg
popd
done
run: .scripts/generate_feature_graphic/generate_feature_graphic.sh
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
Expand Down
47 changes: 47 additions & 0 deletions .scripts/generate_feature_graphic/generate_feature_graphic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -euo pipefail

script_location="$(dirname "$(readlink -f "$0")")"

for lang in "$script_location/../../fastlane/metadata/android/"*; do
pushd "$lang" || exit 1
# Place temporary copy for editing if needed
cp "$script_location/featureGraphic.svg" featureGraphic.svg
if grep -q — title.txt; then
# Try splitting title.txt on — (em dash)
IFS='' read -r appname subtext < title.txt
else
# No result, try splitting on - (dash)
IFS='-' read -r appname subtext < title.txt
fi
export appname=${appname%% }
export subtext=${subtext## }
# If there is subtext, change the .svg accordingly
if [ -n "$subtext" ]; then
perl -pi -e 's/Catima/$ENV{appname}/' featureGraphic.svg
perl -pi -e 's/Loyalty Card Wallet/$ENV{subtext}/' featureGraphic.svg
# Set correct font or font size for language if needed
# (Lexend Deca has limited support and some characters are big)
# We specifically need the Serif version because of the 200 weight
case "$(basename "$lang")" in
bg|el-GR|ru-RU|uk) sed -i "s/Lexend Deca/Noto Serif/" featureGraphic.svg ;;
ja-JP) sed -i "s/Lexend Deca/Noto Serif CJK JP/" featureGraphic.svg ;;
ko) sed -i "s/Lexend Deca/Noto Serif CJK KR/" featureGraphic.svg ;;
kn-IN) sed -i -e 's/font-size="150"/font-size="100"/' -e 's/y="285.511"/y="235.511"/' featureGraphic.svg ;;
zh-CN) sed -i "s/Lexend Deca/Noto Serif CJK SC/" featureGraphic.svg ;;
zh-TW) sed -i "s/Lexend Deca/Noto Serif CJK TC/" featureGraphic.svg ;;
*) ;;
esac
fi
# Ensure images directory exists
mkdir -p images
# Generate .png
convert featureGraphic.svg images/featureGraphic.png
# Optimize .png
optipng images/featureGraphic.png
# Remove metadata (timestamps) from .png
mat2 --inplace images/featureGraphic.png
# Remove temporary .svg
rm featureGraphic.svg
popd || exit 1
done

0 comments on commit a1011e0

Please sign in to comment.