scripts/localize.sh

18 lines · 633 bytes · executable

 1#!/bin/sh
 2# Compiles l10n/Localizable.xcstrings into the .lproj folders of each bundle folder given (an
 3# app's Contents/Resources, an iOS app or extension folder). English is the source language:
 4# its folder is empty, so the keys show as they are.
 5# Usage: scripts/localize.sh <folder>...
 6set -eu
 7
 8cd "$(dirname "$0")/.."
 9work="$(mktemp -d)"
10xcrun xcstringstool compile l10n/Localizable.xcstrings --output-directory "$work" > /dev/null
11mkdir -p "$work/en.lproj"
12for folder in "$@"; do
13    for lproj in "$work"/*.lproj; do
14        rm -rf "$folder/$(basename "$lproj")"
15        cp -R "$lproj" "$folder/"
16    done
17done
18rm -rf "$work"