git: cd71c465b9 - main - tools/translate.sh: Improve usage

"Danilo G. Baio" <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
The branch main has been updated by dbaio:

URL: https://cgit.FreeBSD.org/doc/commit/?id=cd71c465b97d7563bedda9cb265afc91a84c80de

commit cd71c465b97d7563bedda9cb265afc91a84c80de
Author:     Danilo G. Baio <[email protected]>
AuthorDate: 2021-11-20 14:06:22 +0000
Commit:     Danilo G. Baio <[email protected]>
CommitDate: 2021-11-21 12:24:20 +0000

    tools/translate.sh: Improve usage
    
    - Update .po file with the source document before translating.
    
    - Allow translation of a specific document.
    
      Translate all es documents:
       ./tools/translate.sh documentation es
    
      Translate only pt-br articles/bsdl-gpl:
        ./tools/translate.sh documentation pt-br articles/bsdl-gpl
    
    Reviewed by:    fernape
    Differential Revision:  https://reviews.freebsd.org/D33067
---
 tools/translate.sh | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/tools/translate.sh b/tools/translate.sh
index c5a4ab895e..10be78aa05 100755
--- a/tools/translate.sh
+++ b/tools/translate.sh
@@ -54,13 +54,16 @@ fixup_includes()
 }
 
 if [ "$1" = "" ] || [ "$2" = "" ]; then
-	echo "Need to inform which component and|or language."
-	echo "$0 documentation|website pt_BR|es"
+	echo "Need to inform component and language:"
+	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
 fi
 
 COMPONENT="$1"
 LANGUAGE="$2"
+SEARCH_RESTRICT="$3"
 
 # po4a-translate option: -k, --keep
 #   Minimal threshold for translation percentage to keep (i.e. write)
@@ -79,7 +82,7 @@ if [ ! -d "$COMPONENT/content/$LANGUAGE" ]; then
 	exit 1
 fi
 
-for pofile in $(find "$COMPONENT/content/$LANGUAGE/" -name "*.po" ); do
+for pofile in $(find "$COMPONENT/content/$LANGUAGE/$SEARCH_RESTRICT" -name "*.po"); do
 	name=$(basename -s .po "$pofile")
 	if [ "$name" = "chapters-order" ]; then
 		continue
@@ -92,6 +95,19 @@ for pofile in $(find "$COMPONENT/content/$LANGUAGE/" -name "*.po" ); do
 	echo "....."
 	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}~"
+	fi
+
 	po4a-translate \
 		--format asciidoc \
 		--option compat=asciidoctor \
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.