install-new-dict.sh (1534B)
1 #! /usr/bin/env sh 2 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 # This script copies the new dictionary created by make-new-dict in 8 # place. 9 10 set -e 11 12 WKDIR="`pwd`" 13 SUPPORT_DIR="$WKDIR/support_files" 14 SPELLER="$WKDIR/scowl/speller" 15 16 # Stop if backup folders already exist, because it means that this script 17 # has already been run once. 18 FOLDERS=( "orig-bk" "mozilla-bk") 19 for f in ${FOLDERS[@]}; do 20 if [ -d "$SUPPORT_DIR/$f" ]; then 21 echo "Backup folder already present: $f" 22 echo "Run make-new-dict.sh before running this script." 23 exit 1 24 fi 25 done 26 27 mv orig "$SUPPORT_DIR/orig-bk" 28 mkdir orig 29 cp $SPELLER/en_US-custom.dic $SPELLER/en_US-custom.aff $SPELLER/README_en_US-custom.txt orig 30 31 mkdir "$SUPPORT_DIR/mozilla-bk" 32 mv ../en-US.dic ../en-US.aff ../README_en_US.txt "$SUPPORT_DIR/mozilla-bk" 33 34 # The affix file is ISO-8859-1, but still need to change the character set to 35 # ISO-8859-1 and remove conversion rules. 36 cp en_US-mozilla.aff utf8/en-US-utf8.aff 37 sed -i "" -e '/^ICONV/d' -e 's/^SET UTF-8$/SET ISO8859-1/' en_US-mozilla.aff 38 39 # Convert the dictionary to ISO-8859-1 40 cp en_US-mozilla.dic utf8/en-US-utf8.dic 41 iconv -f utf-8 -t iso-8859-1 < utf8/en-US-utf8.dic > en_US-mozilla.dic 42 43 cp en_US-mozilla.aff ../en-US.aff 44 cp en_US-mozilla.dic ../en-US.dic 45 mv README_en_US-mozilla.txt ../README_en_US.txt 46 47 echo "New dictionary copied into place. Please commit the changes."