-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support translating Catima app name in feature graphic (#1623)
* Support translating Catima app name in feature graphic Co-authored-by: FC (Fay) Stegerman <[email protected]>
- Loading branch information
1 parent
9e7d51c
commit a1011e0
Showing
2 changed files
with
48 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
47 changes: 47 additions & 0 deletions
47
.scripts/generate_feature_graphic/generate_feature_graphic.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |