Changeset View
Changeset View
Standalone View
Standalone View
tools/translate.sh
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | sed -i '' -E -e "s,include::(.*)shared/en/,include::\1shared/${2}/," \ | ||||
-e "s,\{include-path\}(contrib*),content/en/articles/contributors/\1," \ | -e "s,\{include-path\}(contrib*),content/en/articles/contributors/\1," \ | ||||
-e "s,include-path: content/en/,include-path: content/${2}/," \ | -e "s,include-path: content/en/,include-path: content/${2}/," \ | ||||
-e "s,(include::.*)contrib-develinmemoriam(.*),include::{include-path}contrib-develinmemoriam\2," \ | -e "s,(include::.*)contrib-develinmemoriam(.*),include::{include-path}contrib-develinmemoriam\2," \ | ||||
-e "s,(:chapters-path: |include::)content/en/books,\1content/${2}/books," \ | -e "s,(:chapters-path: |include::)content/en/books,\1content/${2}/books," \ | ||||
"${1}" | "${1}" | ||||
} | } | ||||
if [ "$1" = "" ] || [ "$2" = "" ]; then | if [ "$1" = "" ] || [ "$2" = "" ]; then | ||||
echo "Need to inform which component and|or language." | echo "Need to inform component and language:" | ||||
echo "$0 documentation|website pt_BR|es" | echo " $0 documentation es" | ||||
echo "A third (optional) argument can be informed to translate only a specific document:" | |||||
echo " $0 documentation pt-br articles/bsdl-gpl" | |||||
exit 1 | exit 1 | ||||
fi | fi | ||||
COMPONENT="$1" | COMPONENT="$1" | ||||
LANGUAGE="$2" | LANGUAGE="$2" | ||||
SEARCH_RESTRICT="$3" | |||||
# po4a-translate option: -k, --keep | # po4a-translate option: -k, --keep | ||||
# Minimal threshold for translation percentage to keep (i.e. write) | # Minimal threshold for translation percentage to keep (i.e. write) | ||||
# the resulting file (default: 80). I.e. by default, files have to be | # the resulting file (default: 80). I.e. by default, files have to be | ||||
# translated at least at 80% to get written. | # translated at least at 80% to get written. | ||||
# # KEEP_ENV=10 ./tools/translate.sh documentation pt_BR | # # KEEP_ENV=10 ./tools/translate.sh documentation pt_BR | ||||
KEEP="${KEEP_ENV:-80}" | KEEP="${KEEP_ENV:-80}" | ||||
if [ "$LANGUAGE" = "en" ]; then | if [ "$LANGUAGE" = "en" ]; then | ||||
echo "Language 'en' can't be translated." | echo "Language 'en' can't be translated." | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
if [ ! -d "$COMPONENT/content/$LANGUAGE" ]; then | if [ ! -d "$COMPONENT/content/$LANGUAGE" ]; then | ||||
echo "$COMPONENT/content/$LANGUAGE does not exist." | echo "$COMPONENT/content/$LANGUAGE does not exist." | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
for pofile in $(find "$COMPONENT/content/$LANGUAGE/" -name "*.po" ); do | for pofile in $(find "$COMPONENT/content/$LANGUAGE/$SEARCH_RESTRICT" -name "*.po"); do | ||||
fernape: Extra space before `)` | |||||
name=$(basename -s .po "$pofile") | name=$(basename -s .po "$pofile") | ||||
if [ "$name" = "chapters-order" ]; then | if [ "$name" = "chapters-order" ]; then | ||||
continue | continue | ||||
fi | fi | ||||
dirbase=$(dirname "$pofile") | dirbase=$(dirname "$pofile") | ||||
adoc_lang="$dirbase/$name.adoc" | adoc_lang="$dirbase/$name.adoc" | ||||
adoc_orig=$(echo "$adoc_lang" | sed s,$COMPONENT/content/$LANGUAGE,$COMPONENT/content/en,) | adoc_orig=$(echo "$adoc_lang" | sed s,$COMPONENT/content/$LANGUAGE,$COMPONENT/content/en,) | ||||
echo "....." | echo "....." | ||||
echo "$pofile" | echo "$pofile" | ||||
po4a-updatepo \ | |||||
--format asciidoc \ | |||||
--option compat=asciidoctor \ | |||||
--option yfm_keys=title,part,description \ | |||||
--master "$adoc_orig" \ | |||||
--master-charset "UTF-8" \ | |||||
--copyright-holder "The FreeBSD Project" \ | |||||
--package-name "FreeBSD Documentation" \ | |||||
--po "$pofile" | |||||
if [ -f "${pofile}~" ]; then | |||||
rm -f "${pofile}~" | |||||
Done Inline Actions"$dirbase/$name.po" ---> "${pofile}" fernape: "$dirbase/$name.po" ---> "${pofile}"
"$dirbase/$name.po~" ---> "${pofile}~" | |||||
fi | |||||
po4a-translate \ | po4a-translate \ | ||||
--format asciidoc \ | --format asciidoc \ | ||||
--option compat=asciidoctor \ | --option compat=asciidoctor \ | ||||
--option yfm_keys=title,part,description \ | --option yfm_keys=title,part,description \ | ||||
--master "$adoc_orig" \ | --master "$adoc_orig" \ | ||||
--master-charset "UTF-8" \ | --master-charset "UTF-8" \ | ||||
--po "$pofile" \ | --po "$pofile" \ | ||||
--localized "$adoc_lang" \ | --localized "$adoc_lang" \ | ||||
--localized-charset "UTF-8" \ | --localized-charset "UTF-8" \ | ||||
--keep "$KEEP" | --keep "$KEEP" | ||||
fixup_lists "${adoc_lang}" | fixup_lists "${adoc_lang}" | ||||
fixup_includes "${adoc_lang}" "${LANGUAGE}" | fixup_includes "${adoc_lang}" "${LANGUAGE}" | ||||
done | done | ||||
Extra space before )