Update download-language-packs.sh

Signed-off-by: Cristian Cezar Moisés <ethicalhacker@riseup.net>
This commit is contained in:
Cristian Cezar Moisés
2025-01-03 23:06:22 +00:00
committed by GitHub
parent 871f320de7
commit cd03077b77

View File

@@ -1,4 +1,5 @@
set -ex
#!/bin/bash
set -euo pipefail # Exit immediately if a command exits with a non-zero status, treat unset variables as errors, and fail on pipe errors.
CURRENT_DIR=$(pwd)
@@ -7,45 +8,50 @@ git config --global init.defaultBranch main
git config --global fetch.prune true
# Clone the Firefox localization repository
cd "$CURRENT_DIR/l10n"
git clone https://github.com/mozilla-l10n/firefox-l10n
L10N_DIR="$CURRENT_DIR/l10n"
FIREFOX_L10N_REPO="https://github.com/mozilla-l10n/firefox-l10n"
mkdir -p "$L10N_DIR" # Ensure the l10n directory exists
cd "$L10N_DIR"
if [ ! -d "firefox-l10n" ]; then
git clone "$FIREFOX_L10N_REPO"
else
echo "The repository 'firefox-l10n' already exists. Pulling the latest changes."
cd firefox-l10n
git pull origin main
cd ..
fi
# Function to update language files
update_language() {
langId=$1
cd "$CURRENT_DIR/l10n/$langId"
LANG_DIR="$L10N_DIR/$langId"
echo "Updating $langId"
echo "Updating $langId..."
# Move the contents from ../firefox-l10n/$langId to ./l10n/$langId
rsync -av --progress "../firefox-l10n/$langId/" . --exclude .git
# Check if the language directory exists
if [ -d "../firefox-l10n/$langId" ]; then
rsync -av --progress "../firefox-l10n/$langId/" "$LANG_DIR/" --exclude .git
else
echo "Warning: Language directory '$langId' does not exist in the repository."
fi
}
# Set PATH for git-cinnabar
export PATH=~/tools/git-cinnabar:$PATH
# Update all supported languages
while read -r lang; do
update_language "$lang"
done < ./l10n/supported-languages
if [[ -f "$L10N_DIR/l10n/supported-languages" ]]; then
while read -r lang; do
update_language "$lang"
done < "$L10N_DIR/l10n/supported-languages"
else
echo "Error: 'supported-languages' file not found."
exit 1
fi
# Move all the files to the correct location
sh scripts/copy-language-pack.sh en-US
while read -r lang; do
sh scripts/copy-language-pack.sh "$lang"
done < ./l10n/supported-languages
wait
# Clean up temporary files
echo "Cleaning up"
rm -rf ~/tools
rm -rf ~/.git-cinnabar
# Remove files that do not start with "zen"
while read -r lang; do
find "./l10n/$lang" -type f -not -name "zen*" -delete
done < ./l10n/supported-languages
# Remove the cloned repository
rm -rf ./l10n/firefox-l10n
done < "$L10N_DIR/l10n/supported-languages"