blob: f65f58a074895a4ffd6c48a333b03b10e5939ce9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
#/bin/bash
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This script builds translated XHP file with helpex executable
# and this transform it to html pages
# 1) generates redirection from LibreOffice Help URL to right html page
# in index.html with bookmark2file.js
# 2) generates bookmark_<APP>.js for index search
# 3) generates HTML pages with online_transform.xs
# 4) copy service files (css, js, media) to right place.
#
# Note: change rootHelpex variable to your local git build
#
# convert2HTML $outDirLang $outDirHTML $lang $productversion $online $fileTree &
function get_bookmark(){
lang=$1
productversion=$2
#workDir=$(realpath $3)
workDir=$(pwd)
outDir=$(realpath $workDir/html/$productversion/$lang)
#sourceDir=$(realpath $workDir/l10n/$lang/helpcontent2/source)
sourceDir=$(realpath $workDir/l10n/$productversion/$lang)
bookmarkFile=$outDir/bookmarks.js
mkdir -p $outDir
rm -f $bookmarkFile
touch $bookmarkFile
stub2=\'
stub1='document.getElementsByClassName( "index" )[0].innerHTML='\'\\
echo $stub1 >> $bookmarkFile
xslfile=get_bookmark.xsl
param1=' --stringparam Language '$lang' --stringparam productversion '$productversion' --stringparam local no'
# bookmarks for modules
for i in WRITER CALC DRAW IMPRESS CHART MATH BASIC
do
sfind=$sourceDir'/'$(echo 'text/s'$i | tr '[:upper:]' '[:lower:]')
param=$param1' --stringparam app '$i
tempFile=$(mktemp)
find $sfind -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $tempFile
sort -k3b -t\> -s -o $tempFile $tempFile
awk 'NF' $tempFile >> $bookmarkFile
rm -f $tempFile
done
# Case of SHARED
tempFile=$(mktemp)
param=$param1' --stringparam app SHARED'
find $sourceDir'/text/shared' -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $tempFile
sort -k3b -t\> -s -o $tempFile $tempFile
awk 'NF' $tempFile >> $bookmarkFile
rm -f $tempFile
# Case of Explorer (BASE)
tempFile=$(mktemp)
param=$param1' --stringparam app BASE'
find $sourceDir'/text/shared/explorer/database' -type f -name "*.xhp" -exec xsltproc $param $xslfile {} + >> $tempFile
sort -k3b -t\> -s -o $tempFile $tempFile
awk 'NF' $tempFile >> $bookmarkFile
rm -f $tempFile
echo $stub2 >> $bookmarkFile
}
function convert2HTML() {
#outDirLang =1
#outDirHTML =2
#lang =3
#productversion =4
#online=5
#filetree=6
###########################################
#
# Process translated XHP files
#
###########################################
xsltparm='--stringparam fileTree '$6' --stringparam local no --stringparam Language '$3' --stringparam productversion '$4' --stringparam root '$1'/'
echo 'Conversion to HTML started for '$3
for filep in $(find $1/text -name "*.xhp")
do
DIR=${filep##*text/}
name=${DIR:0:-3}
outFile=$2'/text/'$name'html'
xsltproc $xsltparm -o $outFile online_transform.xsl $filep
done
###########################################
#
# Process tree files
#
###########################################
treePOFile=$(mktemp)
echo $root/translations/source/$3/helpcontent2/source/auxiliary.po > $treePOFile
ALL_TREE='sbasic.tree scalc.tree schart.tree shared.tree simpress.tree smath.tree swriter.tree'
xhpFiles=$here/l10n/$productversion/$3/text
treeFileHTML=$outDirHTML/contents.js
rm -f $treeFileHTML
touch $treeFileHTML
echo 'document.getElementById("Contents").innerHTML='$'\047''\'>$treeFileHTML
xsltparm='--stringparam lang '$3' --stringparam productversion '$4' --stringparam local no'
for tree in $ALL_TREE
do
treeSourceFile=$root'/helpcontent2/source/auxiliary/'$tree
treeTemp1=$(mktemp)
treeTemp2=$(mktemp)
"${exedir}/treex" -l $3 -i $treeSourceFile -m $treePOFile -o $treeTemp1 -r $xhpFiles
xsltproc $xsltparm -o $treeTemp2 get_tree.xsl $treeTemp1
awk 'NF' $treeTemp2>>$treeFileHTML
rm -f $treeTemp1 $treeTemp2
done
echo $'\047'';'>>$treeFileHTML
rm -f $treePOFile
echo 'Conversion to HTML finished for '$3
}
###########################################
#
# Start Main Process
#
###########################################
# Change root of git core
productversion='6.1'
local='no'
fileTree='/'
rootHelpex=/home/tdf/git/core
ALL_LANGS='en-US am ar ast bg bn bn-IN bo bs ca ca-valencia cs da de dz el en-GB en-ZA eo es et eu fi fr gl gu he hi hr hu id is it ja ka km ko lo lt lv mk nb ne nl nn om pl pt-BR pt ro ru sid si sk sl sq sv ta tg tr ug uk vi zh-CN zh-TW'
here=$(pwd)
root=$(realpath "$here/../..")
rm -rf $here/l10n
rm -rf $here/html
helpfiles=$root/helpcontent2/source/text
mkdir -p $here'/html/'$productversion
echo 'copy global service files'
cp index.html $here'/html/'
cp help.html $here'/html/'
cp index2.html $here'/html/'$productversion'/index.html'
cp help.js $here'/html/'$productversion'/'
cp fuse.js $here'/html/'$productversion'/'
cp paginathing.js $here'/html/'$productversion'/'
cp normalize.css $here'/html/'$productversion'/'
cp default.css $here'/html/'$productversion'/'
cp -a ../source/media $here'/html/'$productversion'/'
mkdir -p $here'/html/'$productversion'/media/icon-themes'
cp -a ../../icon-themes/colibre/* $here'/html/'$productversion'/media/icon-themes/'
ln -s $productversion html/latest
# Set helpex utility and environment
while test ! -d "${rootHelpex}/instdir/program" ; do
if test "${dir}" = "/"; then
echo "error: cannot find \"program\" dir from \"$(pwd)\""
exit 1
fi
rootHelpex=$(realpath "${rootHelpex}/..")
done
exedir="${rootHelpex}"/workdir/LinkTarget/Executable
echo $exedir
export URE_BOOTSTRAP=file://"${rootHelpex}"/instdir/program/fundamentalrc123
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}"${rootHelpex}"/instdir/program
echo "setting URE_BOOTSTRAP to: ${URE_BOOTSTRAP}"
echo "setting search path to: ${LD_LIBRARY_PATH}"
echo "execing: ${exedir}/helpex"
###########################################
#
# Create the hid2file map
#
###########################################
stub1='var map={'
stub2='};'
ffile='html/'$productversion'/hid2file.js'
ffile2=/tmp/tmpbkm.txt
rm -f $ffile2 $ffile
find $helpfiles -type f -name "*.xhp" -exec xsltproc get_url.xsl {} + > $ffile2
echo $stub1 >> $ffile
awk 'NF' $ffile2 >> $ffile
echo $stub2 >> $ffile
###########################################
#
# Process languages
#
###########################################
for lang in $ALL_LANGS
do
echo 'Processing Language '$lang
outDirLang=$here'/l10n/'$productversion'/'$lang
mkdir -p $outDirLang
outDirHTML=$here'/html/'$productversion'/'$lang
mkdir -p $outDirHTML
# Special case of en-US, there is no translation to do
if [ "$lang" == en-US ];
then
cp -a $helpfiles $outDirLang
else
# Create first all translations of xhp
translations=$root/translations/source/$lang/helpcontent2/source/text/
pofiles=`mktemp`
xhpfiles=`mktemp`
# gather all po files of dir
find $translations -type f >$pofiles
# For each po file
for ff in $(cat $pofiles)
do
echo 'Processing po file: '$ff
potemp=`mktemp`
echo $ff>$potemp
name=${ff:0:-3}
stub=${name##*text/}
hlpFileDir=$helpfiles'/'$stub
outDir=$outDirLang'/text/'$stub
mkdir -p $outDir
ls $hlpFileDir/*.xhp >$xhpfiles
"${exedir}/helpex" -l $lang -mi $xhpfiles -m $potemp -o $outDir
rm -f $potemp
done
fi
#extracting bookmarks
echo 'Extracting bookmarks'
get_bookmark $lang $productversion $(pwd)/html &
# converting to HTML
convert2HTML $outDirLang $outDirHTML $lang $productversion $local $fileTree &
rm -f $pofiles $xhpfiles
done
exit
|