Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 1 | # Aap recipe for Portuguese Vim spell files. |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 2 | # |
| 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 Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 17 | |
| 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 | |
| 24 | SPELLDIR = .. |
| 25 | FILES = pt_PT.aff pt_PT.dic |
| 26 | pt_BR.aff pt_BR.dic |
| 27 | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 28 | # |
| 29 | # Fetching the pt_PT files from the Natura project. |
| 30 | # |
| 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 |
| 34 | |
| 35 | # |
| 36 | # Fetching the pt_BR files from BrOffice.org (Brazilian OOo) 2.1. Should be |
| 37 | # updated really soon. |
| 38 | # |
Bram Moolenaar | 10c5695 | 2007-05-10 18:38:52 +0000 | [diff] [blame] | 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 |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 42 | |
| 43 | :attr {fetch = $BR_DIR} $BR_FNAME |
| 44 | |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 45 | all: $SPELLDIR/pt.latin1.spl $SPELLDIR/pt.utf-8.spl \ |
| 46 | ../README_pt.txt |
| 47 | |
| 48 | $SPELLDIR/pt.latin1.spl : $FILES |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 49 | :sys env LANG=pt_PT.ISO8859-1 LC_ALL=pt_PT.ISO8859-1 |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 50 | $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q |
| 51 | |
| 52 | $SPELLDIR/pt.utf-8.spl : $FILES |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 53 | :sys env LANG=pt_PT.UTF-8 LC_ALL=pt_PT.UTF-8 |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 54 | $VIM -u NONE -e -c "mkspell! $SPELLDIR/pt pt_PT pt_BR" -c q |
| 55 | |
| 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 |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 61 | :print Information is in Leia-me.pdf, see $BR_DIR >>$target |
| 62 | :cat README_pt_BR.txt >>$target |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 63 | |
| 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 |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 68 | :fetch $PT_FNAME |
| 69 | :sys $UNZIP $PT_FNAME |
| 70 | :delete $PT_FNAME |
| 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 |
| 75 | :deldir myspell.pt-* |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 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 |
| 82 | |
| 83 | pt_BR.aff pt_BR.dic: {buildcheck=} |
| 84 | :assertpkg unzip patch |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 85 | :fetch $BR_FNAME |
| 86 | :sys $UNZIP $BR_FNAME |
| 87 | :delete $BR_FNAME |
| 88 | :move Leia-me.pdf Leia-me_pt_BR.pdf |
| 89 | |
| 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 |
| 95 | |
| 96 | # Removing /* ... */ header to avoid warnings. Write it to the README file, it |
| 97 | # contains the copyright notice. |
Bram Moolenaar | 10c5695 | 2007-05-10 18:38:52 +0000 | [diff] [blame] | 98 | :sys $VIM pt_BR.aff -e -c "set ff=unix" -c "/\/\*/,/\*\//w! README_pt_BR.txt" -c "/\/\*/,/\*\//+1d" -c update -c q |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 99 | |
| 100 | #:sys $VIM README_pt_BR.txt -e -c "set ff=unix" -c update -c q |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 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 |
| 107 | |
| 108 | |
| 109 | # Generate diff files, so that others can get the OpenOffice files and apply |
| 110 | # the diffs to get the Vim versions. |
| 111 | |
| 112 | diff: |
| 113 | :assertpkg diff |
| 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 |
| 118 | |
| 119 | |
| 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. |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 122 | # TO BE IMPLEMENTED |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 123 | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 124 | check: check-pt check-br |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 125 | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 126 | check-pt: |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 127 | :assertpkg unzip diff |
| 128 | :fetch pt_PT.zip |
| 129 | :mkdir tmp |
| 130 | :cd tmp |
| 131 | @try: |
| 132 | @import stat |
| 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 |
| 140 | @finally: |
| 141 | :cd .. |
| 142 | :delete {r}{f}{q} tmp |
| 143 | :delete pt_PT.zip |
| 144 | |
Bram Moolenaar | c81e5e7 | 2007-05-05 18:24:42 +0000 | [diff] [blame] | 145 | check-br: |
Bram Moolenaar | e344bea | 2005-09-01 20:46:49 +0000 | [diff] [blame] | 146 | :assertpkg unzip diff |
| 147 | :fetch pt_BR.zip |
| 148 | :mkdir tmp |
| 149 | :cd tmp |
| 150 | @try: |
| 151 | @import stat |
| 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 |
| 159 | @finally: |
| 160 | :cd .. |
| 161 | :delete {r}{f}{q} tmp |
| 162 | :delete pt_BR.zip |
| 163 | |
| 164 | # vim: set sts=4 sw=4 : |