Skip to content

Commit

Permalink
tools/prepare-multi-lang.sh: use all CPUs when setting up typemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
eighthave committed Mar 31, 2020
1 parent a9cb8e5 commit 8d14f77
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions tools/prepare-multi-lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Content-type: text/html
TXT
}


if [ ! -f _config.yml ]; then
echo "Must be run from the same directory as _config.yml (the Jekyll source dir)."
exit 1
Expand Down Expand Up @@ -136,7 +137,7 @@ source tools/weblate-supported-langs.sh

cd $1

# For deploying to GitLab or surge.sh, we still want it to work, which
# For deploying to GitLab Pages, we still want it to work, which
# requires leaving original English *.html files in the webroot rather
# than just MultiView compatible *.html.LANG files.
if [[ $# == 2 && $2 == "--no-type-maps" ]]; then
Expand All @@ -145,8 +146,9 @@ else
MULTI_VIEWS=true
fi

find en/ -type f -print0 | while IFS= read -r -d '' FILE_PATH
do
i=0
nproc=`nproc`
find en/ -type f -print0 | while IFS= read -r -d '' FILE_PATH; do
DIR=${FILE_PATH#*/} # Strip off the leading "en/" from the path
DIR=`dirname ${DIR}`
FILE=`basename ${FILE_PATH}`
Expand All @@ -163,16 +165,23 @@ do
continue;
fi

echo "Processing ${DIR}/${FILE}"

for LANG in $SUPPORTED_LANGS; do
SRC_I18N_FILE=${LANG}/${DIR}/${FILE}
DEST_I18N_FILE=${DIR}/${FILE}.${LANG}
assert_file ${SRC_I18N_FILE}
relative_symlink ${SRC_I18N_FILE} ${DEST_I18N_FILE}
done

write_typemap ${DIR}/${FILE} "$SUPPORTED_LANGS"
(
echo "Processing ${DIR}/${FILE}"

for LANG in $SUPPORTED_LANGS; do
SRC_I18N_FILE=${LANG}/${DIR}/${FILE}
DEST_I18N_FILE=${DIR}/${FILE}.${LANG}
assert_file ${SRC_I18N_FILE}
relative_symlink ${SRC_I18N_FILE} ${DEST_I18N_FILE}
done

write_typemap ${DIR}/${FILE} "$SUPPORTED_LANGS"
) &
i=$((i+1))
if [ $i -gt $nproc ]; then
wait
i=0
fi
done

if [[ ${MULTI_VIEWS} = true ]]; then
Expand Down

0 comments on commit 8d14f77

Please sign in to comment.