1 # download dictionaries
3 Function DownloadHunspellDictionary
4 # Downloads hunspell dictionaries from a location that is given in the file
5 # $INSTDIR\Resources\HunspellDictionaryNames.txt
7 # read out the locations from the file
8 FileOpen $R5 "$INSTDIR\Resources\HunspellDictionaryNames.txt" r
9 ${For} $5 1 132 # the file has 132 lines
11 FileRead $R5 $String # $String is now the dictionary name
12 StrCpy $R3 $String -6 # $R3 is now the dictionary language code
14 ${if} $DictCode == $R3
15 StrCpy $String $String -2 # delete the linebreak characters at the end
16 # Download hunspell dictionaries,
17 # if first download repository is not available try the other ones listed in "DictionaryMirrors.txt"
18 FileOpen $R4 "$INSTDIR\Resources\DictionaryMirrors.txt" r
21 FileRead $R4 $Search # $Search is now the mirror
22 StrCpy $Search $Search -2 # delete the linebreak characters at the end
24 InetLoad::load /TIMEOUT=5000 "http://$Search.dl.sourceforge.net/project/lyxwininstaller/hunspell/$String" "$INSTDIR\Resources\dicts\$String" /END
34 MessageBox MB_OK|MB_ICONEXCLAMATION "$(HunspellFailed)"
37 ${endif} # end if $DictCode == $R3
43 Delete "$INSTDIR\$String"
47 #--------------------------------
49 Function DownloadThesaurusDictionary
50 # Downloads thesaurus dictionaries from a location that is given in the file
51 # $INSTDIR\Resources\ThesaurusDictionaryNames.txt
53 # read out the locations from the file
54 FileOpen $R5 "$INSTDIR\Resources\ThesaurusDictionaryNames.txt" r
55 ${For} $5 1 44 # the file has 44 lines
57 FileRead $R5 $String # $String is now the dictionary name
58 StrCpy $R3 $String 5 3 # $R3 is now the dictionary language code
60 ${if} $ThesCode == $R3
61 StrCpy $String $String -2 # delete the linebreak characters at the end
62 # Download thesaurus dictionaries,
63 # if first download repository is not available try the other ones listed in "DictionaryMirrors.txt"
64 FileOpen $R4 "$INSTDIR\Resources\DictionaryMirrors.txt" r
67 FileRead $R4 $Search # $Search is now the mirror
68 StrCpy $Search $Search -2 # delete the linebreak characters at the end
70 InetLoad::load /TIMEOUT=5000 "http://$Search.dl.sourceforge.net/project/lyxwininstaller/thesaurus/$String" "$INSTDIR\Resources\thes\$String" /END
80 MessageBox MB_OK|MB_ICONEXCLAMATION "$(ThesaurusFailed)"
83 ${endif} # end if $ThesCode == $R3
89 Delete "$INSTDIR\$String"
93 #--------------------------------
95 Function InstallHunspellDictionary
96 # install the selected hunspell dictionaries except of already existing ones
98 # download the dictionaries
100 # take the first code
102 StrCpy $String $DictCodes
104 ${if} $Pointer != "-1"
105 StrCpy $DictCode $DictCodes $Pointer
106 # remove the taken code from the list
107 IntOp $Pointer $Pointer + 1
108 StrCpy $DictCodes $DictCodes "" $Pointer
110 # don't dowload existing ones thus check if $DictCode is in $FoundDict
111 StrCpy $String $FoundDict
112 StrCpy $Search $DictCode
113 Call StrPoint # function from LyXUtils.nsh
114 ${if} $Pointer == "-1"
115 Call DownloadHunspellDictionary
117 ${LoopUntil} $DictCodes == ""
121 #--------------------------------
123 Function InstallThesaurusDictionary
124 # install the selected thesaurus dictionaries except of already existing ones
126 # download the dictionaries
128 # all codes have 5 characters
129 StrCpy $ThesCode $ThesCodes 5 # take the first code
130 StrCpy $ThesCodes $ThesCodes "" 5 # remove the taken code from the list
131 # don't dowload existing ones thus check if $ThesCode is in $FoundThes
132 StrCpy $String $FoundThes
133 StrCpy $Search $ThesCode
134 Call StrPoint # function from LyXUtils.nsh
135 ${if} $Pointer == "-1"
136 Call DownloadThesaurusDictionary
138 ${LoopUntil} $ThesCodes == ""
140 # some dictionaries of language variants are identic
141 # therefore copy and rename an existing dictionary
142 CreateDirectory "$INSTDIR\Resources\backup"
143 ${if} ${FileExists} "$INSTDIR\Resources\thes\th_de_DE_v2.dat"
144 CopyFiles "$INSTDIR\Resources\thes\th_de_DE_v2.*" "$INSTDIR\Resources\backup"
145 Rename "$INSTDIR\Resources\backup\th_de_DE_v2.dat" "$INSTDIR\Resources\backup\th_de_AT_v2.dat"
146 Rename "$INSTDIR\Resources\backup\th_de_DE_v2.idx" "$INSTDIR\Resources\backup\th_de_AT_v2.idx"
147 CopyFiles "$INSTDIR\Resources\backup\th_de_AT_v2.*" "$INSTDIR\Resources\thes"
149 ${if} ${FileExists} "$INSTDIR\Resources\thes\th_en_US_v2.dat"
150 CopyFiles "$INSTDIR\Resources\thes\th_en_US_v2.*" "$INSTDIR\Resources\backup"
151 Rename "$INSTDIR\Resources\backup\th_en_US_v2.dat" "$INSTDIR\Resources\backup\th_en_AU_v2.dat"
152 Rename "$INSTDIR\Resources\backup\th_en_US_v2.idx" "$INSTDIR\Resources\backup\th_en_AU_v2.idx"
153 CopyFiles "$INSTDIR\Resources\backup\th_en_AU_v2.*" "$INSTDIR\Resources\thes"
155 RMDir "$INSTDIR\Resources\backup"