summaryrefslogtreecommitdiff
path: root/bin/install-dictionaries
blob: 03c4ba26b8b8acbdc317b6162cf96f87015fc4b6 (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
#!/bin/sh

#
# See setup for user tweakables.
#
. ./setup

if test "z$1" != "z"; then
    DICTDIR=$1;
else
    DICTDIR=$OOINSTDIR/share/dict/ooo
fi

if (! test -d $DICTDIR); then
    echo "Cannot find $DICTDIR; make sure you installed OOo first"
    exit 1;
fi

DICTDIRBASE=`echo $DICTDIR | sed "s|^$OODESTDIR||"`

# the available dictionaries
DICTS="hyph_bg_BG
	hyph_cs_CZ
	hyph_da_DK
	hyph_de_CH
	hyph_de_DE
	hyph_el_GR
	hyph_en_CA
	hyph_en_GB
	hyph_en_US
	hyph_es_ES
	hyph_et_EE
	hyph_fi_FI
	hyph_fr_BE
	hyph_fr_FR
	hyph_ga_IE
	hyph_hu_HU
	hyph_id_ID
	hyph_is_IS
	hyph_it_IT
	hyph_lt_LT
	hyph_nl_NL
	hyph_pl_PL
	hyph_pt_PT
	hyph_pt_BR
	hyph_ru_RU
	hyph_sk_SK
	hyph_sl
	hyph_sv_SE
	hyph_uk
	hyph_uk_UA
	thes_bg_BG
	thes_cs_CZ
	thes_de_DE
	thes_en_US
	thes_es_ES
	thes_fr_FR
	thes_hu_HU
	thes_pl_PL
	bg_BG
	ca_ES
	da_DK
	de_AT
	de_CH
	de_DE_comb
	el_GR
	en_AU
	en_CA
	en_US
	en_NZ
	es_ES
	es_MX
	et_EE
	fr_BE
	fr_FR
	hr_HR
	hu_HU
	la
	nb_NO
	nl_NL
	nn_NO
	pl_PL
	pt_BR
	pt_PT
	ru_RU
	sk_SK
	sl_SI
	sv_SE
	uk_UA"

install_dic()
{
    test -f $1/$2 && mv $1/$2 $DICTDIR/ && echo "$DICTDIRBASE/$2" >>$DICTFILELIST
}

install_doc()
{
    if test -f $1/$2 ; then
	# recode to UTF-8 if needed
	coding=`LC_CTYPE=$3 locale -k LC_CTYPE | grep charmap | sed "s|charmap=\"\(.*\)\"\$|\1|"`
	recode utf8..utf16 <$1/$2 >/dev/null 2>&1 || recode $coding..utf8 $1/$2
	# install
	mv $1/$2 $DOCDIR/dictionaries || exit 1;
	echo "$DOCDIRBASE/dictionaries/$2" >>$DICTFILELIST
	doc_installed=true
    fi
}

#file list
if test "z$OODESTDIR" != "z" ; then
    DICTFILELIST="$BUILDDIR/dictionaries"
    rm -f $DICTFILELIST
else
    DICTFILELIST=/dev/null
fi

doc_installed=false
for DICT in $DICTS ; do
  if test -f $SRCDIR/$DICT.tar.bz2 ; then
    echo "Unpacking $DICT dictionary..."
    mkdir -m 755 -p $DOCDIR/dictionaries
    TMPDIR=`mktemp -d /tmp/ooo-build.dict.XXXXXX`
    tar -xjf $SRCDIR/$DICT.tar.bz2 -C $TMPDIR || exit 1;
    chmod 644 $TMPDIR/*.* || exit 1;
    
    # dictionaries
    DICTNAME=${DICT/thes/th}
    install_dic $TMPDIR $DICTNAME.dic
    install_dic $TMPDIR $DICTNAME.dat
    install_dic $TMPDIR $DICTNAME.idx
    install_dic $TMPDIR $DICTNAME.aff

    # documentation
    LOCALE=${DICT/hyph_/}
    LOCALE=${LOCALE/thes_/}
    LOCALE=`echo $LOCALE | cut -d_ -f1-2`
    for file in `ls $TMPDIR` ; do
	install_doc $TMPDIR $file $LOCALE
    done
    rmdir $TMPDIR || exit 1; 
  else
    echo "Warning: $DICT dictionary is not available..."
  fi
done

if $doc_installed ; then
    echo "%dir $DOCDIRBASE"	      		>>$DICTFILELIST
    echo "%dir $DOCDIRBASE/dictionaries" 	>>$DICTFILELIST
fi

echo "Creating dictionary.lst..."
$TOOLSDIR/bin/install-dict.in $DICTDIR
test -f $DICTDIR/dictionary.lst && echo "$DICTDIRBASE/dictionary.lst" >>$DICTFILELIST