1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-07 17:15:30 +02:00

Discard changes to scripts/download-language-packs.sh

This commit is contained in:
mr. m 2025-01-12 16:34:09 +01:00 committed by GitHub
parent 2b7580f186
commit 143218913d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,64 +1,50 @@
#!/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.
set -ex
CURRENT_DIR=$(pwd)
# Configure Git settings
git config --global init.defaultBranch main
git config --global fetch.prune true
# Clone the Firefox localization repository
L10N_DIR="$CURRENT_DIR/l10n"
FIREFOX_L10N_REPO="https://github.com/mozilla-l10n/firefox-l10n"
cd $CURRENT_DIR
# Ensure the l10n directory exists
if [ ! -d "$L10N_DIR" ]; then
mkdir -p "$L10N_DIR"
fi
cd ./l10n
git clone https://github.com/mozilla-l10n/firefox-l10n
cd $CURRENT_DIR
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() {
local langId=$1
local LANG_DIR="$L10N_DIR/$langId"
echo "Updating $langId..."
langId=$1
cd ./l10n
cd $langId
# 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
echo "Updating $langId"
# move the contents from ../firefox-l10n/$langId to ./l10n/$langId
rsync -av --progress ../firefox-l10n/$langId/ . --exclude .git
cd $CURRENT_DIR
}
# Set PATH for git-cinnabar
export PATH=~/tools/git-cinnabar:$PATH
# Update all supported languages
SUPPORTED_LANGUAGES_FILE="$L10N_DIR/l10n/supported-languages"
if [[ -f "$SUPPORTED_LANGUAGES_FILE" ]]; then
while read -r lang; do
update_language "$lang"
done < "$SUPPORTED_LANGUAGES_FILE"
else
echo "Error: 'supported-languages' file not found."
exit 1
fi
for lang in $(cat ./l10n/supported-languages); do
update_language $lang
done
cd $CURRENT_DIR
# 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 < "$SUPPORTED_LANGUAGES_FILE"
sh scripts/copy-language-pack.sh en-US
for lang in $(cat ./l10n/supported-languages); do
sh scripts/copy-language-pack.sh $lang
done
wait
echo "Cleaning up"
rm -rf ~/tools
rm -rf ~/.git-cinnabar
for lang in $(cat ./l10n/supported-languages); do
# remove every file except if it starts with "zen"
find ./l10n/$lang -type f -not -name "zen*" -delete
done
rm -rf ./l10n/firefox-l10n