blob: 9256a9b2b2bef59e97c5cef1d566aeaaf7b9965d [file] [log] [blame]
Bram Moolenaare344bea2005-09-01 20:46:49 +00001# Aap recipe for Portuguese Vim spell files.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00002#
3# Based on a shell script by Leonardo Fontenelle.
4# His remarks:
5#
6# Makes a Vim pt dictionary from OpenOffice.org's pt_BR and pt_PT.
7#
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.
16
Bram Moolenaare344bea2005-09-01 20:46:49 +000017
18# Use a freshly compiled Vim if it exists.
19@if os.path.exists('../../../src/vim'):
20 VIM = ../../../src/vim
21@else:
22 :progsearch VIM vim
23
24SPELLDIR = ..
25FILES = pt_PT.aff pt_PT.dic
26 pt_BR.aff pt_BR.dic
27
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000028#
29# Fetching the pt_PT files from the Natura project.
30#
31PT_DIR = http://natura.di.uminho.pt/download/sources/Dictionaries/myspell
32PT_FNAME = myspell.pt-latest.zip
33:attr {fetch = $PT_DIR/%file%} $PT_FNAME
34
35#
36# Fetching the pt_BR files from BrOffice.org (Brazilian OOo) 2.1. Should be
37# updated really soon.
38#
39BR_DIR = http://www.deso-se.com.br/downloads/download.php?arquivo=pt_BR-2700g
40BR_FNAME = pt_BR-2700g.zip
41
42:attr {fetch = $BR_DIR} $BR_FNAME
43
Bram Moolenaare344bea2005-09-01 20:46:49 +000044all: $SPELLDIR/pt.latin1.spl $SPELLDIR/pt.utf-8.spl \
45 ../README_pt.txt
46
47$SPELLDIR/pt.latin1.spl : $FILES
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000048 :sys env LANG=pt_PT.ISO8859-1 LC_ALL=pt_PT.ISO8859-1
Bram Moolenaare344bea2005-09-01 20:46:49 +000049 $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
50
51$SPELLDIR/pt.utf-8.spl : $FILES
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000052 :sys env LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8
Bram Moolenaare344bea2005-09-01 20:46:49 +000053 $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q
54
55../README_pt.txt: README_pt_PT.txt README_pt_BR.txt
56 :print pt_PT >!$target
57 :cat README_pt_PT.txt | :eval re.sub('\r', '', stdin) >>$target
58 :print =================================================== >>$target
59 :print pt_BR: >>$target
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000060 :print Information is in Leia-me.pdf, see $BR_DIR >>$target
61 :cat README_pt_BR.txt >>$target
Bram Moolenaare344bea2005-09-01 20:46:49 +000062
63# The files don't depend on the .zip file so that we can delete it.
64# Only download the zip file if the targets don't exist.
65pt_PT.aff pt_PT.dic: {buildcheck=}
66 :assertpkg unzip patch
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000067 :fetch $PT_FNAME
68 :sys $UNZIP $PT_FNAME
69 :delete $PT_FNAME
70 :move myspell.pt-*/pt_PT.dic .
71 :move myspell.pt-*/pt_PT.aff .
72 :move myspell.pt-*/README_pt_PT.txt .
73 :move myspell.pt-*/COPYING COPYING_pt_PT.txt
74 :deldir myspell.pt-*
Bram Moolenaare344bea2005-09-01 20:46:49 +000075 @if not os.path.exists('pt_PT.orig.aff'):
76 :copy pt_PT.aff pt_PT.orig.aff
77 @if not os.path.exists('pt_PT.orig.dic'):
78 :copy pt_PT.dic pt_PT.orig.dic
79 @if os.path.exists('pt_PT.diff'):
80 :sys patch <pt_PT.diff
81
82pt_BR.aff pt_BR.dic: {buildcheck=}
83 :assertpkg unzip patch
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000084 :fetch $BR_FNAME
85 :sys $UNZIP $BR_FNAME
86 :delete $BR_FNAME
87 :move Leia-me.pdf Leia-me_pt_BR.pdf
88
89# 1. pt_BR.dic contains a cp1252-specific character.
90# Changing it to its latin1 equivalent.
91# 2. Vim seems to ignore the dots from the word list.
92# Removing words with dot to avoid misbehaviour.
93 :sys $VIM pt_BR.dic -e -c "set ff=unix" -c "%s/\%x92/'/g" -c "/\./d" -c update -c q
94
95# Removing /* ... */ header to avoid warnings. Write it to the README file, it
96# contains the copyright notice.
97 :sys $VIM pt_BR.aff -e -c "set ff=unix" -c "/\/\*/,/\*\//w README_pt_BR.txt" -c "/\/\*/,/\*\//+1d" -c update -c q
98
99 #:sys $VIM README_pt_BR.txt -e -c "set ff=unix" -c update -c q
Bram Moolenaare344bea2005-09-01 20:46:49 +0000100 @if not os.path.exists('pt_BR.orig.aff'):
101 :copy pt_BR.aff pt_BR.orig.aff
102 @if not os.path.exists('pt_BR.orig.dic'):
103 :copy pt_BR.dic pt_BR.orig.dic
104 @if os.path.exists('pt_BR.diff'):
105 :sys patch <pt_BR.diff
106
107
108# Generate diff files, so that others can get the OpenOffice files and apply
109# the diffs to get the Vim versions.
110
111diff:
112 :assertpkg diff
113 :sys {force} diff -a -C 1 pt_PT.orig.aff pt_PT.aff >pt_PT.diff
114 :sys {force} diff -a -C 1 pt_PT.orig.dic pt_PT.dic >>pt_PT.diff
115 :sys {force} diff -a -C 1 pt_BR.orig.aff pt_BR.aff >pt_BR.diff
116 :sys {force} diff -a -C 1 pt_BR.orig.dic pt_BR.dic >>pt_BR.diff
117
118
119# Check for updated OpenOffice spell files. When there are changes the
120# ".new.aff" and ".new.dic" files are left behind for manual inspection.
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000121# TO BE IMPLEMENTED
Bram Moolenaare344bea2005-09-01 20:46:49 +0000122
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000123check: check-pt check-br
Bram Moolenaare344bea2005-09-01 20:46:49 +0000124
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000125check-pt:
Bram Moolenaare344bea2005-09-01 20:46:49 +0000126 :assertpkg unzip diff
127 :fetch pt_PT.zip
128 :mkdir tmp
129 :cd tmp
130 @try:
131 @import stat
132 :sys $UNZIP ../pt_PT.zip
133 :sys {force} diff ../pt_PT.orig.aff pt_PT.aff >d
134 @if os.stat('d')[stat.ST_SIZE] > 0:
135 :copy pt_PT.aff ../pt_PT.new.aff
136 :sys {force} diff ../pt_PT.orig.dic pt_PT.dic >d
137 @if os.stat('d')[stat.ST_SIZE] > 0:
138 :copy pt_PT.dic ../pt_PT.new.dic
139 @finally:
140 :cd ..
141 :delete {r}{f}{q} tmp
142 :delete pt_PT.zip
143
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000144check-br:
Bram Moolenaare344bea2005-09-01 20:46:49 +0000145 :assertpkg unzip diff
146 :fetch pt_BR.zip
147 :mkdir tmp
148 :cd tmp
149 @try:
150 @import stat
151 :sys $UNZIP ../pt_BR.zip
152 :sys {force} diff ../pt_BR.orig.aff pt_BR.aff >d
153 @if os.stat('d')[stat.ST_SIZE] > 0:
154 :copy pt_BR.aff ../pt_BR.new.aff
155 :sys {force} diff ../pt_BR.orig.dic pt_BR.dic >d
156 @if os.stat('d')[stat.ST_SIZE] > 0:
157 :copy pt_BR.dic ../pt_BR.new.dic
158 @finally:
159 :cd ..
160 :delete {r}{f}{q} tmp
161 :delete pt_BR.zip
162
163# vim: set sts=4 sw=4 :