diff options
| author | Jon Petersson <jon.petersson@mullvad.net> | 2025-09-15 14:54:21 +0200 |
|---|---|---|
| committer | Jon Petersson <jon.petersson@mullvad.net> | 2025-09-16 09:08:20 +0200 |
| commit | 302f3a850d2f2b8b6307677a0f9ab93e3bdf3146 (patch) | |
| tree | f168435d31a25e9bf58453b88e2dd59a911caff2 | |
| parent | 61b39ec0eb2fa6a4059640e3e646442f78e8236f (diff) | |
| download | mullvadvpn-302f3a850d2f2b8b6307677a0f9ab93e3bdf3146.tar.xz mullvadvpn-302f3a850d2f2b8b6307677a0f9ab93e3bdf3146.zip | |
Revert "Add iOS localization to the pipeline"
This reverts commit 32a2024a1d3c4a593e9f134f38babc881b49e7cb.
| -rw-r--r-- | ios/MullvadVPN.xcodeproj/project.pbxproj | 2 | ||||
| -rw-r--r-- | ios/translation/scripts/Readme.md | 4 | ||||
| -rwxr-xr-x | ios/translation/scripts/localizations.sh | 102 | ||||
| -rwxr-xr-x | scripts/localization | 27 |
4 files changed, 53 insertions, 82 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index 5c53868bd4..1cb47be61b 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -5846,7 +5846,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint lint --quiet\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; 580E3F222A9861990061809D /* Run SwiftLint */ = { isa = PBXShellScriptBuildPhase; diff --git a/ios/translation/scripts/Readme.md b/ios/translation/scripts/Readme.md index a01bcbe5b1..44674d7eff 100644 --- a/ios/translation/scripts/Readme.md +++ b/ios/translation/scripts/Readme.md @@ -26,6 +26,8 @@ This folder contains a Bash workflow that: ``` +> **Important:** Ensure `build/` and `logs/` are ignored by Git (see [Git Ignore](#git-ignore)). + --- ## Quick Start @@ -91,3 +93,5 @@ logs/ 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 629d501b4e..2129e3aa5a 100755 --- a/ios/translation/scripts/localizations.sh +++ b/ios/translation/scripts/localizations.sh @@ -1,14 +1,16 @@ #!/usr/bin/env bash # localizations.sh -# Exports strings from and Imports them to an Xcode project. +# Exports Swift/SwiftUI localization files (.xliff) from 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)" + PROJECT_NAME="MullvadVPN" SCHEME_NAME="$PROJECT_NAME" XCODE_PROJECT_PATH="$SCRIPT_DIR/../../$PROJECT_NAME.xcodeproj" @@ -25,63 +27,54 @@ 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..." - if ! xcodebuild \ + echo "๐ Building project..." + 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 >"$TMP_LOG" 2>&1; then - echo "Failed to build project" - on_fail - fi - echo "Build succeeded" + clean build + 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 - # Run xcodebuild and capture errors - if ! xcodebuild -exportLocalizations \ + echo "โก๏ธ Exporting $lang" + xcodebuild -exportLocalizations \ -project "$XCODE_PROJECT_PATH" \ -scheme "$SCHEME_NAME" \ -derivedDataPath "$DERIVED_DATA_DIR" \ -localizationPath "$TMP_EXPORT_DIR" \ - -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 + -exportLanguage "$lang" local xcloc_dir="${TMP_EXPORT_DIR}/${lang}.xcloc" @@ -90,13 +83,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 @@ -105,7 +98,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 @@ -115,13 +108,16 @@ 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 @@ -141,63 +137,61 @@ import_localizations() { # 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" \ - -quiet \ - CODE_SIGNING_REQUIRED=NO \ - CODE_SIGNING_ALLOWED=NO \ - >"$TMP_LOG" 2>&1; then - echo "Failed to import $xliff_file" - on_fail + -disableAutomaticPackageResolution; then + echo "โ Failed to import $xliff_file" + exit 1 fi done - echo "All localizations imported successfully." + echo "โ
All localizations imported successfully." } localization_to_export() { - LOG_FILE="$LOG_DIR/export-localization_$(date +%Y%m%d_%H%M%S).log" + echo "๐ Export script started at: $(date)" 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 "๐ Export complete. Crowdin-ready .xliff files are in: $LOCALIZATION_DIR" + echo "โ
Script finished at: $(date)" rm -f "$TMP_LOG" } localization_to_import() { - LOG_FILE="$LOG_DIR/import-localization_$(date +%Y%m%d_%H%M%S).log" + echo "๐ Import script started at: $(date)" build_project import_localizations cleanup_build_folder cleanup_temp_folder - echo "Import complete. Localized .xliff files have been imported to code" + echo "๐ Import complete. Localized .xliff files have been imported to code" + echo "โ
Script finished at: $(date)" 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 } diff --git a/scripts/localization b/scripts/localization index ac0bf99240..084f61661c 100755 --- a/scripts/localization +++ b/scripts/localization @@ -62,9 +62,6 @@ function prepare_localization_strings { update_relay_locations_pot commit_changes "Update relay-locations.pot" - - update_ios_strings export - commit_changes "Update en.xliff" } function ensure_crowdin_api_key { @@ -80,11 +77,6 @@ function upload_to_crowdin { crowdin upload sources crowdin upload translations popd - - pushd ../ios/translation - crowdin upload sources - crowdin upload translations - popd } function download_from_crowdin { @@ -95,17 +87,9 @@ function download_from_crowdin { crowdin download popd - pushd ../ios/translation - crowdin download - popd - # Add new translations to Android xml-files log_header "Updating Android xml-files with new translations" sync_localizations - - # Add new translations to iOS source code - update_ios_strings import - commit_changes "Update translations" } @@ -126,17 +110,6 @@ function verify { exit 1 fi } -function update_ios_strings { - if [ $# -ne 1 ] || { [ "$1" != "export" ] && [ "$1" != "import" ]; }; then - echo "Usage: update_ios_strings [export|import]" >&2 - return 2 - fi - if [ "$1" = "export" ]; then - log_header "Extracting strings from iOS app source code" - else - log_header "Updating strings into iOS app source code with new translations" - fi -} main "$@" |
