ClickHouse/docs/tools/translate/translate.sh
Ivan Blinkov 2e1f6bc56d
[experimental] add "es" docs language as machine translated draft (#9787)
* replace exit with assert in test_single_page

* improve save_raw_single_page docs option

* More grammar fixes

* "Built from" link in new tab

* fix mistype

* Example of include in docs

* add anchor to meeting form

* Draft of translation helper

* WIP on translation helper

* Replace some fa docs content with machine translation

* add normalize-en-markdown.sh

* normalize some en markdown

* normalize some en markdown

* admonition support

* normalize

* normalize

* normalize

* support wide tables

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* lightly edited machine translation of introdpection.md

* lightly edited machhine translation of lazy.md

* WIP on translation utils

* Normalize ru docs

* Normalize other languages

* some fixes

* WIP on normalize/translate tools

* add requirements.txt

* [experimental] add es docs language as machine translated draft

* remove duplicate script

* Back to wider tab-stop (narrow renders not so well)
2020-03-21 07:11:51 +03:00

23 lines
971 B
Bash
Executable File

#!/usr/bin/env bash
# Usage: translate.sh <target_language> <input> <output>
set -e
BASE_DIR=$(dirname $(readlink -f $0))
OUTPUT=${3:-/dev/stdout}
export TARGET_LANGUAGE="$1"
export DEBUG
TEMP_FILE=$(mktemp)
trap 'rm -f -- "${TEMP_FILE}"' INT TERM HUP EXIT
source "${BASE_DIR}/venv/bin/activate"
pandoc "$2" --filter "${BASE_DIR}/filter.py" -o "${TEMP_FILE}" \
-f "markdown-space_in_atx_header" -t "markdown_strict+pipe_tables+markdown_attribute+all_symbols_escapable+backtick_code_blocks+autolink_bare_uris-link_attributes+markdown_attribute+mmd_link_attributes-raw_attribute+header_attributes-grid_tables" \
--atx-headers --wrap=none --columns=99999 --tab-stop=4
perl -pi -e 's/{\\#\\#/{##/g' "${TEMP_FILE}"
perl -pi -e 's/\\#\\#}/##}/g' "${TEMP_FILE}"
perl -pi -e 's/ *$//gg' "${TEMP_FILE}"
if [[ "${TARGET_LANGUAGE}" == "ru" ]]
then
perl -pi -e 's/“/«/gg' "${TEMP_FILE}"
perl -pi -e 's/”/»/gg' "${TEMP_FILE}"
fi
cat "${TEMP_FILE}" > "${OUTPUT}"