Annotation of mailredirect/src/make-lang.sh, revision 1.2

1.1       krzesnia    1: #!/bin/sh
                      2: 
                      3: # make-lang.sh v1.0.10
                      4: # this script is used to create a language-specifi XPI for mailredirect
                      5: # ported from enigmail make-lang.sh (enigmail.mozdev.org)
                      6: 
                      7: # if you want to debug this script, set DEBUG to something >0
                      8: DEBUG=0
                      9: 
1.2     ! krzesnia   10: MAILREDIRECTVERSION=${2:-`cat version.txt`}
        !            11: export MAILREDIRECTVERSION
        !            12: 
1.1       krzesnia   13: if [ $# -gt 2 -o $# -lt 1 ]; then
                     14:   echo "Usage: $0 xx-YY [version]"
                     15:   echo "       where: xx-YY   is the language and country code representing the"
                     16:   echo "                      translated language (e.g. pl-PL, de-DE, es-ES)"
1.2     ! krzesnia   17:   echo "              version (optional) is the Mail Redirect version, e.g. ${MAILREDIRECTVERSION}"
        !            18:   echo "                      if parameter is not given value from version.txt is taken"
1.1       krzesnia   19:   exit 1
                     20: fi
                     21: 
                     22: MAILREDIRECTLANG=$1
                     23: export MAILREDIRECTLANG
                     24: 
1.2     ! krzesnia   25: LANGDIR=${MAILREDIRECTLANG}/chrome/locale/${MAILREDIRECTLANG}
1.1       krzesnia   26: cwd=`pwd`
                     27: rm -rf ${LANGDIR} >/dev/null 2>&1
                     28: mkdir -p ${LANGDIR} 
                     29: 
                     30: LANGHASH=`echo "${MAILREDIRECTLANG}" | md5sum | awk '{ print substr($0,0,2)}'`
                     31: export LANGHASH
                     32: 
                     33: # create install.js
                     34: cat > ${MAILREDIRECTLANG}/install.js <<EOT
1.2     ! krzesnia   35: // Install script for mailredirect ${MAILREDIRECTLANG} language pack
1.1       krzesnia   36: 
                     37: // 1. Set parameters of package installation
                     38: const APP_DISPLAY_NAME = "Mail Redirect ${MAILREDIRECTLANG} language pack";
                     39: const APP_NAME = "mailredirect";
                     40: const APP_VERSION = "${MAILREDIRECTVERSION}";
                     41: 
                     42: const APP_PACKAGE = "/" + APP_NAME;
                     43: const APP_JAR_FILE = APP_NAME + "-${MAILREDIRECTLANG}.jar";
1.2     ! krzesnia   44: const APP_CONTENT_FOLDER = "content/";
        !            45: const APP_LOCALE_FOLDER = "locale/${MAILREDIRECTLANG}/";
1.1       krzesnia   46: 
                     47: 
                     48: const INST_TO_PROFILE = "Do you wish to install "+APP_DISPLAY_NAME+" to your profile?\nThis will mean it does not need reinstalling when you update your application.\n(Click Cancel if you want "+APP_DISPLAY_NAME+" installing to the application directory.)";
                     49: 
                     50: 
                     51: // 2. Initialise package
                     52: initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
                     53: 
                     54: // Get package directories
                     55: // profile installs only work since 2003-03-06
                     56: var instToProfile = false;
                     57: // var instToProfile = ((buildID>2003030600 || buildID==0000000000) && confirm(INST_TO_PROFILE));
                     58: var chromef = instToProfile ? getFolder("Profile", "chrome") : getFolder("chrome");
                     59: 
                     60: // 3. Flag files/folders to be added
                     61: addFile("", "chrome/" + APP_JAR_FILE, chromef, "");
                     62: 
                     63: err = getLastError();
                     64: 
                     65: if (err == SUCCESS) {
                     66: 
                     67:   // 4. Register chrome (this is what contents.rdf is used for)
                     68:   if(instToProfile) {
                     69:     registerChrome(LOCALE  | PROFILE_CHROME, getFolder(chromef, APP_JAR_FILE), APP_LOCALE_FOLDER);
                     70:   } else {
                     71:     registerChrome(LOCALE  | DELAYED_CHROME, getFolder(chromef, APP_JAR_FILE), APP_LOCALE_FOLDER);
                     72:   }
                     73: 
                     74:   // 5. Perform the installation
                     75:   err = performInstall();
                     76: 
                     77:   // 6. Report on success or otherwise  
                     78:   if(err == SUCCESS || err == 999) {
                     79:     refreshPlugins();
                     80:     alert(APP_DISPLAY_NAME+" "+APP_VERSION+" has been succesfully installed.\nYou need to restart Mozilla first.");
                     81:   } else {
                     82:     alert("Install failed. Error code: " + err);
                     83:     cancelInstall(err);
                     84:   }
                     85: } else {
                     86:   alert("Failed to create JAR file.\n"
                     87:     +"You probably don't have appropriate permissions \n"
                     88:     +"(write access to your profile or chrome directory). \n"
                     89:     +"_____________________________\nError code:" + err);
                     90:   cancelInstall(err);
                     91: }
                     92: EOT
                     93: 
                     94: # create install.rdf for Thunderbird 0.7 and newer
                     95: cat > ${MAILREDIRECTLANG}/install.rdf <<EOT
                     96: <?xml version="1.0"?>
                     97: 
                     98: <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
                     99: 
                    100:   <Description about="urn:mozilla:install-manifest">
                    101:     <em:id>{CC3C233D-66${LANGHASH}-41bc-AAEB-F3A1D1D594F5}</em:id> 
                    102:     <em:name>Mail Redirect ${MAILREDIRECTLANG}</em:name>
                    103:     <em:version>${MAILREDIRECTVERSION}</em:version>
                    104:     <em:description>Mail Redirect ${MAILREDIRECTLANG} language package</em:description>
                    105: 
                    106:     <!-- Author of the package, replace with your name if you like -->
                    107:     <em:creator>Pawe&#322; Krze&#347;niak</em:creator>
                    108: 
                    109:     <em:homepageURL>http://mailredirect.mozdev.org/langpack.html</em:homepageURL>
                    110:     <em:optionsURL>chrome://mailredirect/content/mailredirect-prefs.xul</em:optionsURL>
                    111:     <em:iconURL>chrome://mailredirect/skin/mailredirect-icon.png</em:iconURL>
                    112: 
                    113:     <em:file>
                    114:       <Description about="urn:mozilla:extension:file:mailredirect-${MAILREDIRECTLANG}.jar">
1.2     ! krzesnia  115:         <em:locale>locale/${MAILREDIRECTLANG}/</em:locale>
1.1       krzesnia  116:       </Description>
                    117:     </em:file>
                    118:     
                    119:     <em:targetApplication>
                    120:       <Description>
                    121:         <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
                    122:         <em:minVersion>0.7</em:minVersion>
1.2     ! krzesnia  123:         <em:maxVersion>1.6+</em:maxVersion>
1.1       krzesnia  124:       </Description>
                    125:     </em:targetApplication>
                    126:   
                    127:   </Description>
                    128: 
                    129: </RDF>
                    130: EOT
                    131: 
                    132: cat >${LANGDIR}/contents.rdf <<EOT
                    133: <?xml version="1.0"?>
                    134: <RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                    135:          xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
                    136: 
                    137:   <!-- list all the locales being supplied by this jar -->
                    138:   <RDF:Seq about="urn:mozilla:locale:root">
                    139:     <RDF:li resource="urn:mozilla:locale:${MAILREDIRECTLANG}"/>
                    140:   </RDF:Seq>
                    141: 
                    142:   <!-- list packages for which locale information is provided -->
                    143:    <RDF:Description about="urn:mozilla:locale:${MAILREDIRECTLANG}">
                    144:     <chrome:packages>
                    145:       <RDF:Seq about="urn:mozilla:locale:${MAILREDIRECTLANG}:packages">
                    146:         <RDF:li resource="urn:mozilla:locale:${MAILREDIRECTLANG}:mailredirect"/>
                    147:       </RDF:Seq>
                    148:     </chrome:packages>
                    149:   </RDF:Description>
                    150: 
                    151: </RDF:RDF> 
                    152: EOT
                    153: 
1.2     ! krzesnia  154: cat >${LANGDIR}/chrome.manifest <<EOT
        !           155: locale mailredirect    ${MAILREDIRECTLANG}     jar:chrome/mailredirect-${MAILREDIRECTLANG}.jar!/locale/${MAILREDIRECTLANG}/
        !           156: EOT
        !           157: 
        !           158: cd ${cwd}/locale/en-US
1.1       krzesnia  159: for f in aw.dtd mailredirect.dtd mailredirect-compose.dtd mailredirect-compose.properties mailredirect-prefs.dtd mailredirect-prefs.properties ; do
                    160:   cp ${f} ${cwd}/${LANGDIR}
                    161: done
                    162: 
                    163: cd ${cwd}/${MAILREDIRECTLANG}/chrome
                    164: zip -r -D mailredirect-${MAILREDIRECTLANG}.jar locale
                    165: cd ..
1.2     ! krzesnia  166: zip ../mailredirect-${MAILREDIRECTLANG}-${MAILREDIRECTVERSION}.xpi install.js install.rdf chrome.manifest chrome/mailredirect-${MAILREDIRECTLANG}.jar
1.1       krzesnia  167: cd ..
                    168: 
                    169: test $DEBUG -eq 0 && rm -rf ${MAILREDIRECTLANG}
1.2     ! krzesnia  170: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>