Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#!/bin/bashset -euo pipefailshopt -s nullglobroot=$(cd "$(dirname "$0")/.." && pwd)
check=falseif [[ "${1:-}" == --check ]]; then check=true shiftfilanguage_args=()if [[ "${1:-}" == --language && $# -ge 2 ]]; then language_args=(--language "$2") shift 2fiif [[ $# -ne 2 || "${1:-}" == -* ]]; then printf 'Usage: %s [--check] [--language locale] resources-directory output-directory\n' "$0" >&2 exit 2firesources="$(cd "$1" && pwd)"output="$2"catalogs=("$resources"/*.xcstrings)if [[ ${#catalogs[@]} -eq 0 ]]; then printf 'No String Catalogs found in %s\n' "$resources" >&2 exit 1fi
mkdir -p "$output"output="$(cd "$output" && pwd)"staging="$(mktemp -d "$output/.staging.XXXXXX")"trap 'rm -rf -- "$staging"' EXITtrap 'exit 1' HUP INT TERM
# A failed catalog must not leave the build's tables partially regenerated.for catalog in "${catalogs[@]}"; do prepared="$staging/$(basename "$catalog")" # Catalog entries without translations still need their source-language keys in the bundle. "$root/Scripts/parcel-dev.sh" prepare-catalog "$catalog" "$prepared" xcrun xcstringstool compile "$prepared" --output-directory "$staging" --serialization-format text ${language_args[@]+"${language_args[@]}"}done
status=0for generated in "$staging"/*.lproj/*.strings "$staging"/*.lproj/*.stringsdict; do relative="${generated#"$staging"/}" destination="$output/$relative" if "$check"; then if ! cmp -s "$generated" "$destination"; then printf 'Out-of-date generated resource: %s\n' "$destination" >&2 status=1 fi else mkdir -p "$(dirname "$destination")" cp "$generated" "$destination" fidone
for existing in "$output"/*.lproj/*.strings "$output"/*.lproj/*.stringsdict; do relative="${existing#"$output"/}" if [[ ! -f "$staging/$relative" ]]; then if "$check"; then printf 'Unexpected generated resource: %s\n' "$existing" >&2 status=1 else rm -- "$existing" fi fidone
if [[ $status -ne 0 ]]; then printf 'Run Scripts/generate-config-strings.sh with these directories to regenerate catalog outputs.\n' >&2fiexit "$status"