1 # Aap recipe for Portuguese Vim spell files.
3 # Based on a shell script by Leonardo Fontenelle.
6 # Makes a Vim pt dictionary from OpenOffice.org's pt_BR and pt_PT.
8 # AFAIK, will have to update the script every time a new dictionary is
9 # released for pt_BR. I asked the maintainer to update OOo's FTP site,
10 # but it didn't happen yet. As for the pt_PT dictionary, they won't be
11 # in OOo's FTP site for some time, because the Portuguese OOo project
12 # decided to adapt the pt_BR dictionary, which is much more extensive.
13 # I picked the Natura project unofficial dictionary, because it has been
14 # developed by a team with linguists, and for a longer time. At least the
15 # pt_PT dictionary has a "latest" file to make our lives easier.
18 # Use a freshly compiled Vim if it exists.
19 @if os.path.exists('../../../src/vim'):
20 VIM = ../../../src/vim
25 FILES = pt_PT.aff pt_PT.dic
29 # Fetching the pt_PT files from the Natura project.
31 PT_DIR = http://natura.di.uminho.pt/download/sources/Dictionaries/myspell
32 PT_FNAME = myspell.pt-latest.zip
33 :attr {fetch = $PT_DIR/%file%} $PT_FNAME
36 # Fetching the pt_BR files from BrOffice.org (Brazilian OOo) 2.1. Should be
37 # updated really soon.
39 BR_BASENAME = pt_BR-2007-04-11
40 BR_DIR = http://www.deso-se.com.br/downloads/download.php?arquivo=$BR_BASENAME
41 BR_FNAME = $(BR_BASENAME).zip
43 :attr {fetch = $BR_DIR} $BR_FNAME
45 all: $SPELLDIR/pt.latin1.spl $SPELLDIR/pt.utf-8.spl \
48 $SPELLDIR/pt.latin1.spl : $FILES
49 :sys env LANG=pt_PT.ISO8859-1 LC_ALL=pt_PT.ISO8859-1
50 $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
52 $SPELLDIR/pt.utf-8.spl : $FILES
53 :sys env LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8
54 $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
56 ../README_pt.txt: README_pt_PT.txt README_pt_BR.txt
57 :print pt_PT >!$target
58 :cat README_pt_PT.txt | :eval re.sub('\r', '', stdin) >>$target
59 :print =================================================== >>$target
60 :print pt_BR: >>$target
61 :print Information is in Leia-me.pdf, see $BR_DIR >>$target
62 :cat README_pt_BR.txt >>$target
64 # The files don't depend on the .zip file so that we can delete it.
65 # Only download the zip file if the targets don't exist.
66 pt_PT.aff pt_PT.dic: {buildcheck=}
67 :assertpkg unzip patch
71 :move myspell.pt-*/pt_PT.dic .
72 :move myspell.pt-*/pt_PT.aff .
73 :move myspell.pt-*/README_pt_PT.txt .
74 :move myspell.pt-*/COPYING COPYING_pt_PT.txt
76 @if not os.path.exists('pt_PT.orig.aff'):
77 :copy pt_PT.aff pt_PT.orig.aff
78 @if not os.path.exists('pt_PT.orig.dic'):
79 :copy pt_PT.dic pt_PT.orig.dic
80 @if os.path.exists('pt_PT.diff'):
81 :sys patch <pt_PT.diff
83 pt_BR.aff pt_BR.dic: {buildcheck=}
84 :assertpkg unzip patch
88 :move Leia-me.pdf Leia-me_pt_BR.pdf
90 # 1. pt_BR.dic contains a cp1252-specific character.
91 # Changing it to its latin1 equivalent.
92 # 2. Vim seems to ignore the dots from the word list.
93 # Removing words with dot to avoid misbehaviour.
94 :sys $VIM pt_BR.dic -e -c "set ff=unix" -c "%s/\%x92/'/g" -c "/\./d" -c update -c q
96 # Removing /* ... */ header to avoid warnings. Write it to the README file, it
97 # contains the copyright notice.
98 :sys $VIM pt_BR.aff -e -c "set ff=unix" -c "/\/\*/,/\*\//w! README_pt_BR.txt" -c "/\/\*/,/\*\//+1d" -c update -c q
100 #:sys $VIM README_pt_BR.txt -e -c "set ff=unix" -c update -c q
101 @if not os.path.exists('pt_BR.orig.aff'):
102 :copy pt_BR.aff pt_BR.orig.aff
103 @if not os.path.exists('pt_BR.orig.dic'):
104 :copy pt_BR.dic pt_BR.orig.dic
105 @if os.path.exists('pt_BR.diff'):
106 :sys patch <pt_BR.diff
109 # Generate diff files, so that others can get the OpenOffice files and apply
110 # the diffs to get the Vim versions.
114 :sys {force} diff -a -C 1 pt_PT.orig.aff pt_PT.aff >pt_PT.diff
115 :sys {force} diff -a -C 1 pt_PT.orig.dic pt_PT.dic >>pt_PT.diff
116 :sys {force} diff -a -C 1 pt_BR.orig.aff pt_BR.aff >pt_BR.diff
117 :sys {force} diff -a -C 1 pt_BR.orig.dic pt_BR.dic >>pt_BR.diff
120 # Check for updated OpenOffice spell files. When there are changes the
121 # ".new.aff" and ".new.dic" files are left behind for manual inspection.
124 check: check-pt check-br
127 :assertpkg unzip diff
133 :sys $UNZIP ../pt_PT.zip
134 :sys {force} diff ../pt_PT.orig.aff pt_PT.aff >d
135 @if os.stat('d')[stat.ST_SIZE] > 0:
136 :copy pt_PT.aff ../pt_PT.new.aff
137 :sys {force} diff ../pt_PT.orig.dic pt_PT.dic >d
138 @if os.stat('d')[stat.ST_SIZE] > 0:
139 :copy pt_PT.dic ../pt_PT.new.dic
142 :delete {r}{f}{q} tmp
146 :assertpkg unzip diff
152 :sys $UNZIP ../pt_BR.zip
153 :sys {force} diff ../pt_BR.orig.aff pt_BR.aff >d
154 @if os.stat('d')[stat.ST_SIZE] > 0:
155 :copy pt_BR.aff ../pt_BR.new.aff
156 :sys {force} diff ../pt_BR.orig.dic pt_BR.dic >d
157 @if os.stat('d')[stat.ST_SIZE] > 0:
158 :copy pt_BR.dic ../pt_BR.new.dic
161 :delete {r}{f}{q} tmp
164 # vim: set sts=4 sw=4 :