Files
ALR/scripts/i18n-precommit.sh
Евгений (ХрамычЪ) Храмов 737bf68f95
Some checks failed
Pre-commit / pre-commit (push) Failing after 5m14s
исправление i18n-precommit
2025-08-26 22:43:39 +03:00

63 lines
2.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# ALR - Any Linux Repository
# Copyright (C) 2025 The ALR Authors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Wrapper script for i18n that automatically stages changed files for pre-commit
set -e
# Сохраняем состояние файлов до выполнения i18n
TRANSLATION_FILES=(
"internal/translations/default.pot"
"internal/translations/po/ru/default.po"
"assets/i18n-ru-badge.svg"
)
# Создаем временные файлы для сравнения
TEMP_DIR=$(mktemp -d)
for file in "${TRANSLATION_FILES[@]}"; do
if [[ -f "$file" ]]; then
cp "$file" "$TEMP_DIR/$(basename "$file")"
fi
done
# Выполняем обновление переводов
make i18n
# Проверяем какие файлы изменились и добавляем их в staging area
CHANGED_FILES=()
for file in "${TRANSLATION_FILES[@]}"; do
if [[ -f "$file" ]]; then
if [[ ! -f "$TEMP_DIR/$(basename "$file")" ]] || ! cmp -s "$file" "$TEMP_DIR/$(basename "$file")"; then
CHANGED_FILES+=("$file")
fi
fi
done
# Добавляем измененные файлы в git staging area
if [[ ${#CHANGED_FILES[@]} -gt 0 ]]; then
echo "Auto-staging changed translation files:"
for file in "${CHANGED_FILES[@]}"; do
echo " - $file"
git add "$file"
done
fi
# Очищаем временные файлы
rm -rf "$TEMP_DIR"
# Выход с кодом 0 (успех) даже если файлы были изменены
exit 0