Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/tools/update_translate_template.sh
18080 views
1
#!/bin/sh
2
#
3
# Copyright (c) 2021 Danilo G. Baio <[email protected]>
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions are met:
7
#
8
# 1. Redistributions of source code must retain the above copyright notice, this
9
# list of conditions and the following disclaimer.
10
#
11
# 2. Redistributions in binary form must reproduce the above copyright notice,
12
# this list of conditions and the following disclaimer in the documentation
13
# and/or other materials provided with the distribution.
14
#
15
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26
27
ALL_COMPONENTS="documentation
28
website"
29
30
COMPONENTS="${1:-$ALL_COMPONENTS}"
31
32
GIT_IGNORE_FILES="toc-examples.adoc
33
toc-figures.adoc
34
toc-tables.adoc
35
toc.adoc
36
toc-1.adoc
37
toc-2.adoc
38
toc-3.adoc
39
toc-4.adoc
40
toc-5.adoc"
41
42
IGNORE_FILES="contrib-386bsd
43
contrib-additional
44
contrib-committers
45
contrib-corealumni
46
contrib-develalumni
47
contrib-portmgralumni"
48
49
for remove_file in $GIT_IGNORE_FILES; do
50
find documentation/content/en/ -name "$remove_file" -delete -print || exit 1
51
done
52
53
for component in $COMPONENTS; do
54
55
if [ ! -d "$component/content/en" ]; then
56
echo "Directory '$component/content/en' not found."
57
exit 1
58
fi
59
60
for document in $(find "$component/content/en/" -name "*.adoc" ); do
61
name=$(basename -s .adoc "$document")
62
63
# Ignore some files
64
if [ "$name" = "chapters-order" ]; then
65
continue
66
fi
67
68
if [ "$document" = "documentation/content/en/books/books.adoc" ]; then
69
continue
70
fi
71
72
if echo "$IGNORE_FILES" | grep -q -w "$name"; then
73
continue
74
fi
75
76
dirbase=$(dirname "$document")
77
echo "$document"
78
79
po4a-updatepo \
80
--format asciidoc \
81
--option compat=asciidoctor \
82
--option tablecells=1 \
83
--option yfm_keys=title,part,description \
84
--master "$document" \
85
--master-charset "UTF-8" \
86
--copyright-holder "The FreeBSD Project" \
87
--package-name "FreeBSD Documentation" \
88
--po "$dirbase/$name.po"
89
if [ -f "$dirbase/$name.po~" ]; then
90
rm -f "$dirbase/$name.po~"
91
fi
92
done
93
done
94
95
96