summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormojganii <mojgan.jelodar@mullvad.net>2025-10-22 16:03:16 +0200
committermojganii <mojgan.jelodar@mullvad.net>2025-10-27 10:10:39 +0100
commit5c98ae2c15fc4a7207fd0b4eb8bc7113826f6535 (patch)
tree5930fda05c663ea50071eb4645415c519110d9d9
parent7b9537edb6d83f6d19c6b0d407cfd81780b3fef7 (diff)
downloadmullvadvpn-5c98ae2c15fc4a7207fd0b4eb8bc7113826f6535.tar.xz
mullvadvpn-5c98ae2c15fc4a7207fd0b4eb8bc7113826f6535.zip
Silence localization script to reduce CLI log
-rw-r--r--ios/translation/scripts/Readme.md7
-rwxr-xr-xios/translation/scripts/localizations.sh105
2 files changed, 55 insertions, 57 deletions
diff --git a/ios/translation/scripts/Readme.md b/ios/translation/scripts/Readme.md
index 44674d7eff..7350a53354 100644
--- a/ios/translation/scripts/Readme.md
+++ b/ios/translation/scripts/Readme.md
@@ -17,7 +17,7 @@ This folder contains a Bash workflow that:
```
/mullvadvpn-app/ios/translation
├── locales
-│   └── en.xliff
+│ └── en.xliff
└── scripts
├── localizations.sh # Main Bash script
├── build # Ephemeral DerivedData or build scratch dir (ignored)
@@ -26,8 +26,6 @@ This folder contains a Bash workflow that:
```
-> **Important:** Ensure `build/` and `logs/` are ignored by Git (see [Git Ignore](#git-ignore)).
-
---
## Quick Start
@@ -92,6 +90,3 @@ logs/
build_20250723_142915.log
build_20250724_094401.log
```
-
-To prune logs older than 7 days automatically, the script includes an optional cleanup step (disabled by default; enable by setting `PRUNE_LOGS_DAYS`).
-
diff --git a/ios/translation/scripts/localizations.sh b/ios/translation/scripts/localizations.sh
index 76bb1eef2f..7f7d413bd7 100755
--- a/ios/translation/scripts/localizations.sh
+++ b/ios/translation/scripts/localizations.sh
@@ -1,16 +1,14 @@
#!/usr/bin/env bash
# localizations.sh
-# Exports Swift/SwiftUI localization files (.xliff) from an Xcode project.
+# Exports strings from and Imports them to an Xcode project.
-#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_DIR="$SCRIPT_DIR/logs"
mkdir -p "$LOG_DIR"
-LOG_FILE="$LOG_DIR/export-localization_$(date +%Y%m%d_%H%M%S).log"
-TMP_LOG="$(mktemp)"
+TMP_LOG="$(mktemp)"
PROJECT_NAME="MullvadVPN"
SCHEME_NAME="$PROJECT_NAME"
XCODE_PROJECT_PATH="$SCRIPT_DIR/../../$PROJECT_NAME.xcodeproj"
@@ -27,54 +25,63 @@ trap 'on_fail' ERR
on_fail() {
set +e
- echo "❌ Export failed. Cleaning up and saving log..."
+ echo "Export failed. Cleaning up and saving log..."
cleanup_build_folder
cleanup_temp_folder
mkdir -p "$(dirname "$LOG_FILE")"
cat "$TMP_LOG" >"$LOG_FILE"
- echo "💥 Full log saved to: $LOG_FILE"
+ echo "Full log saved to: $LOG_FILE"
exit 1
}
cleanup_build_folder() {
- echo "🧹 Cleaning build folder at: $BUILD_OUTPUT_DIR"
rm -rf "$BUILD_OUTPUT_DIR"
}
cleanup_temp_folder() {
- echo "🧹 Cleaning temp folder at: $TMP_EXPORT_DIR"
rm -rf "$TMP_EXPORT_DIR"
}
exec > >(tee "$TMP_LOG") 2>&1
build_project() {
- echo "👉 Building project..."
- xcodebuild \
+ echo "Building project..."
+ if ! xcodebuild \
-project "$XCODE_PROJECT_PATH" \
-scheme "$SCHEME_NAME" \
-destination 'generic/platform=iOS' \
-configuration "$CONFIGURATION" \
-derivedDataPath "$DERIVED_DATA_DIR" \
+ -quiet \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
- clean build
- echo "✅ Build succeeded"
+ clean build >"$TMP_LOG" 2>&1; then
+ echo "Failed to build project"
+ on_fail
+ fi
+ echo "Build succeeded"
}
export_localizations() {
- echo "🌍 Exporting localizations for languages: $EXPORT_LANGUAGES"
+ echo "Exporting localizations for languages: $EXPORT_LANGUAGES"
IFS=',' read -r -a LANG_ARRAY <<<"$EXPORT_LANGUAGES"
for lang in "${LANG_ARRAY[@]}"; do
- echo "➡️ Exporting $lang"
- xcodebuild -exportLocalizations \
+ # Run xcodebuild and capture errors
+ if ! xcodebuild -exportLocalizations \
-project "$XCODE_PROJECT_PATH" \
-scheme "$SCHEME_NAME" \
-derivedDataPath "$DERIVED_DATA_DIR" \
-localizationPath "$TMP_EXPORT_DIR" \
- -exportLanguage "$lang"
+ -exportLanguage "$lang" \
+ -quiet \
+ CODE_SIGNING_REQUIRED=NO \
+ CODE_SIGNING_ALLOWED=NO \
+ >"$TMP_LOG" 2>&1; then
+ echo "Failed to export localization for $lang"
+ on_fail
+ fi
local xcloc_dir="${TMP_EXPORT_DIR}/${lang}.xcloc"
@@ -83,13 +90,13 @@ export_localizations() {
xliff_file=$(find "$xcloc_dir" -name '*.xliff' | head -n 1)
if [[ -f "$xliff_file" ]]; then
cp "$xliff_file" "$LOCALIZATION_DIR/${lang}.xliff"
- echo "✔️ Extracted $lang.xliff for Crowdin upload"
+ echo "Extracted $lang.xliff for Crowdin upload"
else
- echo "❌ No .xliff file found in $xcloc_dir"
+ echo "No .xliff file found in $xcloc_dir"
false
fi
else
- echo "❌ .xcloc bundle not found for $lang"
+ echo ".xcloc bundle not found for $lang"
false
fi
done
@@ -98,7 +105,7 @@ export_localizations() {
clean_xliff_translations() {
xliff_dir="$LOCALIZATION_DIR"
if [[ ! -d "$xliff_dir" ]]; then
- echo "❌ Directory not found: $xliff_dir"
+ echo "Directory not found: $xliff_dir"
return 1
fi
@@ -108,16 +115,13 @@ clean_xliff_translations() {
["CFBundleDisplayName"]=1
# Add more keys here if needed
)
-
- echo "🧹 Cleaning unneeded keys from XLIFFs in $xliff_dir"
for xliff in "$xliff_dir"/*.xliff; do
if [[ -f "$xliff" ]]; then
for key in "${!UNNEEDED_KEYS[@]}"; do
sed -i '' -E "/<trans-unit[^>]*id=\"$key\"[^>]*>/,/<\/trans-unit>/d" "$xliff"
done
- echo "✔️ Cleaned $xliff"
else
- echo "⚠️ File not found: $xliff, skipping"
+ echo "File not found: $xliff, skipping"
fi
done
@@ -131,67 +135,66 @@ import_localizations() {
# Skip if no files found
[ -e "$xliff_file" ] || continue
- # Remove unwanted attributes from the XLIFF file
- # sed -i '' -E 's/ state="needs-review-translation"//g' "$xliff_file"
-
# Extract language code from filename, e.g., fr.xliff → fr
language_code=$(basename "$xliff_file" .xliff)
- echo "📥 Importing localization: $language_code from $xliff_file"
+ echo "Importing localization: $language_code from $xliff_file"
+ # Run xcodebuild and check for errors
if ! xcodebuild -importLocalizations \
-project "$XCODE_PROJECT_PATH" \
-scheme "$SCHEME_NAME" \
-derivedDataPath "$DERIVED_DATA_DIR" \
-localizationPath "$xliff_file" \
-exportLanguage "$language_code" \
- -disableAutomaticPackageResolution; then
- echo "❌ Failed to import $xliff_file"
- exit 1
+ -quiet \
+ CODE_SIGNING_REQUIRED=NO \
+ CODE_SIGNING_ALLOWED=NO \
+ >"$TMP_LOG" 2>&1; then
+ echo "Failed to import $xliff_file"
+ on_fail
fi
done
- echo "✅ All localizations imported successfully."
+ echo "All localizations imported successfully."
}
localization_to_export() {
- echo "📝 Export script started at: $(date)"
+ LOG_FILE="$LOG_DIR/export-localization_$(date +%Y%m%d_%H%M%S).log"
build_project
export_localizations
clean_xliff_translations
cleanup_build_folder
cleanup_temp_folder
- echo "🎉 Export complete. Crowdin-ready .xliff files are in: $LOCALIZATION_DIR"
- echo "✅ Script finished at: $(date)"
+ echo "Export complete. Crowdin-ready .xliff files are in: $LOCALIZATION_DIR"
rm -f "$TMP_LOG"
}
localization_to_import() {
- echo "📝 Import script started at: $(date)"
+ LOG_FILE="$LOG_DIR/import-localization_$(date +%Y%m%d_%H%M%S).log"
build_project
import_localizations
cleanup_build_folder
cleanup_temp_folder
- echo "🎉 Import complete. Localized .xliff files have been imported to code"
- echo "✅ Script finished at: $(date)"
+ echo "Import complete. Localized .xliff files have been imported to code"
rm -f "$TMP_LOG"
}
# Main entrypoint
main() {
case "${1:-}" in
- export)
- localization_to_export
- ;;
- import)
- localization_to_import
- ;;
- "")
- echo "Available subcommands: export, import"
- ;;
- *)
- echo "❌ Unknown parameter: $1"
- exit 1
- ;;
+ export)
+ localization_to_export
+ ;;
+ import)
+ localization_to_import
+ ;;
+ "")
+ echo "Available subcommands: export, import"
+ ;;
+ *)
+ echo "Unknown parameter: $1"
+ exit 1
+ ;;
esac
}