2023-03-15 21:30:44 +03:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2023-11-08 00:30:27 +03:00
|
|
|
# Pulls the latest localization files into a target workspace.
|
2023-03-15 21:30:44 +03:00
|
|
|
|
|
|
|
PACKAGE=$1
|
|
|
|
FOLDER="public/locales"
|
|
|
|
PREFIX="[l10n/prime]"
|
|
|
|
|
|
|
|
if [ -z "$PACKAGE" ]; then
|
|
|
|
echo "$PREFIX: A package must be defined as argument 1."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-03-14 17:41:02 +03:00
|
|
|
#Split PACKAGE by /
|
|
|
|
PACKAGE_FOLDER_ARR=(${PACKAGE//\// })
|
|
|
|
|
|
|
|
# No cd necessary for apps/*
|
|
|
|
# Applications in apps/* should already be in monorepo root
|
|
|
|
if [[ "${PACKAGE_FOLDER_ARR[0]}" == "packages" ]]; then
|
|
|
|
# Move to monorepo root
|
|
|
|
cd "$(dirname "$0")/../.."
|
|
|
|
fi
|
|
|
|
|
2024-03-13 22:47:02 +03:00
|
|
|
ROOT_FOLDER=$(pwd)
|
2024-03-14 17:41:02 +03:00
|
|
|
echo $ROOT_FOLDER
|
2023-03-15 21:30:44 +03:00
|
|
|
|
|
|
|
if [ ! -d "$ROOT_FOLDER/external/l10n/locale" ]; then
|
2023-03-16 22:44:14 +03:00
|
|
|
echo "$PREFIX: No external/l10n folder exists! Run yarn l10n:clone script first."
|
2023-03-15 21:30:44 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check path is valid
|
2024-03-14 17:41:02 +03:00
|
|
|
TARGET_FOLDER="$PACKAGE/$FOLDER"
|
2023-03-15 21:30:44 +03:00
|
|
|
rm -rf "$TARGET_FOLDER"
|
|
|
|
mkdir -p "$TARGET_FOLDER"
|
|
|
|
|
|
|
|
# Loop through all files and combine
|
|
|
|
cd "$ROOT_FOLDER/external/l10n/locale";
|
|
|
|
for d in */; do
|
|
|
|
cd "$d";
|
|
|
|
locale=$(echo $d | sed 's/_/-/' | sed 's/\/$//')
|
|
|
|
count=$(ls | grep .ftl | wc -l)
|
|
|
|
if [[ $((count)) == 0 ]]; then
|
|
|
|
echo "$PREFIX: $locale has no .ftl files"
|
|
|
|
else
|
|
|
|
mkdir -p "$ROOT_FOLDER/$TARGET_FOLDER/$locale"
|
|
|
|
cp *.ftl "$ROOT_FOLDER/$TARGET_FOLDER/$locale/"
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
done
|
2023-03-16 22:44:14 +03:00
|
|
|
|
|
|
|
# Record the current git version
|
|
|
|
cd "$ROOT_FOLDER/external/l10n"
|
|
|
|
git rev-parse HEAD > "$ROOT_FOLDER/$TARGET_FOLDER/git-head.txt"
|