ClickHouse/docs/tools/translate/replace-with-translation.sh
2020-04-04 12:15:31 +03:00

18 lines
492 B
Bash
Executable File

#!/usr/bin/env bash
# Usage: replace-with-translation.sh <target_language> <path>
set -e
BASE_DIR=$(dirname $(readlink -f $0))
TEMP_FILE=$(mktemp)
trap 'rm -f -- "${TEMP_FILE}"' INT TERM HUP EXIT
TARGET_LANGUAGE="$1"
export INPUT="$2"
cat "${INPUT}" > "${TEMP_FILE}"
if [[ ! -z $SLEEP ]]
then
sleep $[ ( $RANDOM % 20 ) + 1 ]s
fi
rm -f "${INPUT}"
mkdir -p $(dirname "${INPUT}") || true
YANDEX=1 "${BASE_DIR}/translate.sh" "${TARGET_LANGUAGE}" "${TEMP_FILE}" "${INPUT}"
git add "${INPUT}"