#!/bin/bash set -euo pipefail shopt -s nullglob root=$(cd "$(dirname "$0")/.." && pwd) if [[ $# -ne 2 || $1 == -* ]]; then printf 'Usage: %s catalog-directory bundle-resources-directory\n' "$0" >&2 exit 2 fi catalogs=("$1"/*.xcstrings) if (( ${#catalogs[@]} == 0 )); then printf 'No String Catalogs found in %s\n' "$1" >&2 exit 1 fi mkdir -p "$2" destination=$(cd "$2" && pwd) if [[ -e $destination/en-XA.lproj || -L $destination/en-XA.lproj ]]; then printf 'Pseudo resources already exist in %s\n' "$destination" >&2 exit 1 fi work=$(mktemp -d "$destination/.pseudo.XXXXXX") trap 'rm -rf "$work"' EXIT mkdir "$work/compiled" for catalog in "${catalogs[@]}"; do prepared="$work/$(basename "$catalog")" "$root/Scripts/parcel-dev.sh" prepare-pseudo-catalog "$catalog" "$prepared" xcrun xcstringstool compile "$prepared" --language en-XA --output-directory "$work/compiled" done [[ -d $work/compiled/en-XA.lproj ]] || { printf 'Compiler produced no pseudo resources.\n' >&2; exit 1; } mv "$work/compiled/en-XA.lproj" "$destination/en-XA.lproj"