Check-in [8c805ffb85]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:8c805ffb85234d92a44718c061c0824846ffe98f
Date: 2012-03-12 01:06:20
User: BarryK
Comment:xdelta_gui t12s conversion broke an if-then, instead of fixing it, changed to rodin.s gettext conversion

Tags And Properties
Changes

Changes to woof-code/rootfs-skeleton/usr/sbin/xdelta_gui

@@ -1,6 +1,6 @@
-#!/bin/ash
+#!/bin/sh
 #(c) Copyright Barry Kauler 2009, puppylinux.com
 #2009 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
 #a frontend for the 'xdelta' utility.
 #$1 is normally invoked by clicking on a .delta file in rox, $1 has full path.
 #also supports drag and drop.
@@ -8,30 +8,24 @@
 #  # xdelta_gui oldfile:newfile.delta <<script searches for oldfile.
 #  # xdelta_gui oldfile newfile       <<script will generate .delta file
 #  # xdelta_gui oldfile genfile.delta <<recreate oldfile
 #...first ex, .delta has old/new files encoded into its own filename.
 #100131 altenate delta file format "oldfile___newfile.delta" (three underscores).
-#111213 L18L: i18n t12s _ M _ method (internationalization of script).
-
-###################### copy this block into any other script that... ##########
-app=`basename $0`
-T=/usr/share/locales # TEXTDOMAINDIR
-# a one-liner to find existing translation file LOCALES allowing 'dialects'
-[ ! -f ${T}/${LANG%.*}/${app} ] && LOCALES=${T}/${LANG%_*}/${app} || LOCALES=${T}/${LANG%.*}/${app}
-[ -f $LOCALES ] && . $LOCALES # (re)load translation file (when using variables)
-###################### ... uses this _ M _ method of internationalization #####
-
-
+#120312 rodin.s: adding gettext.
+
+export TEXTDOMAIN=xdelta_gui
+export OUTPUT_CHARSET=UTF-8
+. gettext.sh
 
 if [ "`which xdelta3`" = "" ];then
- xmessage -center -bg red "${_M_20:-The 'xdelta' package must be installed first}"
+ xmessage -center -bg red "`gettext \"The 'xdelta' package must be installed first\"`"
  exit
 fi
 
 old_find_func () {
  #needs OLDFILENAME, sets SOURCEFILE_OLD.
-	 xmessage -bg orange -center -buttons "" "${_M_15:-Please wait, searching for old file...}" &
+	 xmessage -bg orange -center -buttons "" "$(gettext 'Please wait, searching for old file...')" &
 	 XPID=$!
 	 SOURCEFILE_OLD="`find /root -maxdepth 4 -type f -name ${OLDFILENAME} | head -n 1`"
 	 if [ "$SOURCEFILE_OLD" = "" ];then
       #SOURCEFILE_OLD="`find /mnt/home -maxdepth 4 -type f -name ${OLDFILENAME} | head -n 1`"
 	  for ONEMNTD in `mount | grep '^/dev/sd[a-z]' | cut -f 3 -d ' ' | tr '\n' ' '`
@@ -40,12 +34,11 @@
 	   [ "$SOURCEFILE_OLD" != "" ] && break
 	  done
 	 fi
 	 kill $XPID
      if [ "$SOURCEFILE_OLD" = "" ];then
-      [ -f $LOCALES ] && . $LOCALES # load translation file
-      xmessage -bg yellow -center "${_M_16:-Sorry could not find $OLDFILENAME. You will have to manually drag it into the 'Old file' box}"
+      xmessage -bg yellow -center "`eval_gettext \"Sorry could not find \\\${OLDFILENAME}. You will have to manually drag it into the 'Old file' box\"`"
      fi
 }
 
 SOURCEFILE_OLD=""
 SOURCEFILE_NEW=""
@@ -52,12 +45,11 @@
 SOURCEFILE_DELTA=""
 SOURCEFILE_2ND=""
 if [ $1 ];then
  SOURCEFILE="$1"
  if [ ! -f "$SOURCEFILE" ];then
-  [ -f $LOCALES ] && . $LOCALES # load translation file
-  xmessage -center -bg red "${_M_7:-ERROR: $SOURCEFILE does not exist}"
+  xmessage -center -bg red "`eval_gettext \"ERROR: \\\${SOURCEFILE} does not exist\"`"
   exit
  fi
  if [ "`echo -n "${SOURCEFILE}" | grep '\.delta$'`" = "" ];then
   SOURCEFILE_OLD="$SOURCEFILE"
  else
@@ -119,54 +111,46 @@
 [ "$SOURCEFILE_OLD" != "" ] && DEFAULT_OLD="<default>${SOURCEFILE_OLD}</default>"
 [ "$SOURCEFILE_NEW" != "" ] && DEFAULT_NEW="<default>${SOURCEFILE_NEW}</default>"
 [ "$SOURCEFILE_DELTA" != "" ] && DEFAULT_DELTA="<default>${SOURCEFILE_DELTA}</default>"
 if [ "$DEFAULT_NEW" != "" ];then
  SECONDBOX="<hbox>
-  <text><label>${_M_11:-New file:}</label></text>
+  <text><label>$(gettext 'New file:')</label></text>
   <entry accept=\"directory\">${DEFAULT_NEW}<variable>SOURCEFILE_NEW</variable></entry>
  </hbox>"
 fi
 if [ "$DEFAULT_DELTA" != "" ];then
  SECONDBOX="<hbox>
-  <text><label>${_M_1:-Delta file:}</label></text>
+  <text><label>$(gettext 'Delta file:')</label></text>
   <entry accept=\"directory\">${DEFAULT_DELTA}<variable>SOURCEFILE_DELTA</variable></entry>
  </hbox>"
 fi
 if [ "$SECONDBOX" = "" ];then
  SECONDBOX="<hbox>
-  <text><label>${_M_12:-New or .delta file:}</label></text>
+  <text><label>$(gettext 'New or .delta file:')</label></text>
   <entry accept=\"directory\">${DEFAULT_2ND}<variable>SOURCEFILE_2ND</variable></entry>
  </hbox>"
 fi
 
-# some text: 1 _ M _ per line only, no \n\n , easier to maintain?
-t_t="${_M_10:-HELP}"
-t_m1="${_M_27:-Xdelta is an application program designed to compute changes between two files.}"
-t_m2="${_M_23:-These changes (deltas) are similar to the output of the 'diff' program in that they may be used to store and transmit only the changes between files.  However, unlike diff, the output of Xdelta is not expressed in a human-readable format -- Xdelta can also also apply these deltas to a copy of the original file.  Xdelta uses a fast, linear algorithm and performs well on both binary and text files.}"
-t_m3="${_M_24:-To create a '.delta' file, you need two original files, an 'old' and a 'new' file. The generated delta file will have an extension of '.delta'.}"
-t_m4="${_M_28:-You can recreate the original 'new' file, as long as you have the original 'old' file and the '.delta' file. This GUI frontend makes this easy -- just drag the .delta file into the box, and the progam will search for and locate the original old file. Or, just click on a .delta file in a ROX-Filer window to regenerate the original new file.}"
-t_m5="${_M_19:-The author of Xdelta is Joshua MacDonald.}"
-t_m6="${_M_22:-The Rsync algorithm, which inspired the core delta algorithm, is due to Andrew Tridgell and Paul Mackerras.}"
-t_m7="${_M_21:-The GUI is written by Barry Kauler. Licence is GPL v2.}"
+
 export XDELTA_DLG="
-<window title=\"Xdelta ${_M_2:-difference manager}\" icon-name=\"gtk-file\">
+<window title=\"$(gettext 'Xdelta difference manager')\" icon-name=\"gtk-file\">
 <vbox>
-  <text><label>${_M_26:-Welcome, this is a GUI for the 'xdelta' utility, to manage changes between two files}</label></text>
-   <text use-markup=\"true\"><label>\"<b>${_M_25:-To generate a '.delta' file, drag old and new files here, or to recreate the new file drag old and '.delta' files here} ↓    </b>\"</label></text>
+  <text><label>`gettext \"Welcome, this is a GUI for the 'xdelta' utility, to manage changes between two files\"`</label></text>
+   <text use-markup=\"true\"><label>\"<b>`gettext \"To generate a '.delta' file, drag old and new files here, or to recreate the new file drag old and '.delta' files here\"` ↓    </b>\"</label></text>
 
   <hbox>
-   <text><label>${_M_13:-Old file:}</label></text>
+   <text><label>$(gettext 'Old file:')</label></text>
    <entry accept=\"directory\">${DEFAULT_OLD}<variable>SOURCEFILE_OLD</variable></entry>
   </hbox>
   ${SECONDBOX}
 
   <hbox>
   <button help>
-   <action>Xdialog --wrap --screencenter --left --title \"Xdelta - ${t_t}\" --msgbox \"${t_m1} ${t_m2} \n\n${t_m3}\n\n${t_m4}\n\n${t_m5} ${t_m6} ${t_m7}\" 600x0</action>
+   <action>Xdialog --wrap --screencenter --left --title \"Xdelta - $(gettext 'HELP')\" --msgbox \"`gettext \"Xdelta is an application program designed to compute changes between two files. These changes (deltas) are similar to the output of the 'diff' program in that they may be used to store and transmit only the changes between files.  However, unlike diff, the output of Xdelta is not expressed in a human-readable format -- Xdelta can also also apply these deltas to a copy of the original file.  Xdelta uses a fast, linear algorithm and performs well on both binary and text files.\n\nTo create a '.delta' file, you need two original files, an 'old' and a 'new' file. The generated delta file will have an extension of '.delta'.\n\nYou can recreate the original 'new' file, as long as you have the original 'old' file and the '.delta' file. This GUI frontend makes this easy -- just drag the .delta file into the box, and the progam will search for and locate the original old file. Or, just click on a .delta file in a ROX-Filer window to regenerate the original new file.\n\nThe author of Xdelta is Joshua MacDonald. The Rsync algorithm, which inspired the core delta algorithm, is due to Andrew Tridgell and Paul Mackerras. The GUI is written by Barry Kauler. Licence is GPL v2.\"`\" 600x0</action>
   </button>
   <button cancel></button>
-  <button><label>${_M_8:-GENERATE}</label><action type=\"exit\">generate</action></button>
+  <button><label>$(gettext 'GENERATE')</label><action type=\"exit\">generate</action></button>
   </hbox>
 </vbox>
 </window>"
 
 RETVALS="`gtkdialog3 --program=XDELTA_DLG --center`"
@@ -185,11 +169,11 @@
 fi
 
 if [ "$SOURCEFILE_NEW" != "" ];then
  [ ! -f "$SOURCEFILE_NEW" ] && EXITERR="yes"
  if [ "$EXITERR" != "" ];then
-  xmessage -bg red -center "${_M_3:-Error, 'New file' does not exist}"
+  xmessage -bg red -center "`gettext \"Error, 'New file' does not exist\"`"
   exit
  fi
 fi
 
 if [ "$SOURCEFILE_DELTA" != "" -a "$SOURCEFILE_OLD" = "" ];then
@@ -222,11 +206,11 @@
 fi
 
 [ "$SOURCEFILE_OLD" = "" ] && EXITERR="yes"
 [ ! -f "$SOURCEFILE_OLD" ] && EXITERR="yes"
 if [ "$EXITERR" != "" ];then
- xmessage -bg red -center "${_M_4:-Error, 'Old file' does not exist}"
+ xmessage -bg red -center "`gettext \"Error, 'Old file' does not exist\"`"
  exit
 fi
 
 OLDEXT="`echo -n "$SOURCEFILE_OLD" | rev | cut -f 1 -d '.' | rev`"
 if [ "$SOURCEFILE_DELTA" != "" ];then
@@ -241,20 +225,20 @@
  if [ "`echo -n "$BASEDELTA" | grep '___'`" != "" ];then
   NEWFILENAME="`echo -n "$BASEDELTA" | grep '___' | sed -e 's%^.*___%%' | rev | cut -f 2-9 -d '.' | rev`"
   [ "$NEWFILENAME" != "" ] && SOURCEFILE_NEW="$DIRDELTA/$NEWFILENAME"
  fi
  [ "$SOURCEFILE_NEW" = "" ] && SOURCEFILE_NEW="$DIRDELTA/newfile.${OLDEXT}"
- xmessage -bg orange -center -buttons "" "${_M_14:-please wait...}" & #100131
+ xmessage -bg orange -center -buttons "" "$(gettext 'please wait')..." & #100131
  XMPID=$!
  xdelta3 -d -s "$SOURCEFILE_OLD" "$SOURCEFILE_DELTA" "$SOURCEFILE_NEW" 2>/tmp/xdelta_err
+ XFLG=$?
  sync
  kill $XMPID
- if [ $? -eq 0 ];then
-  [ -f $LOCALES ] && . $LOCALES # load translation file
-  xmessage -bg green -center "${_M_18:-SUCCESS! $SOURCEFILE_NEW generated}"
+ if [ $XFLG -eq 0 ];then
+  xmessage -bg green -center "`eval_gettext \"SUCCESS! \\\${SOURCEFILE_NEW} generated\"`"
  else
-  xmessage -bg red -center "${_M_6:-ERROR! failed to recreate the new file. Error message:}
+  xmessage -bg red -center "$(gettext 'ERROR! failed to recreate the new file. Error message:')
 `cat /tmp/xdelta_err`"
  fi
 else
  #generate a delta file...
  BASE_OLD="`basename "$SOURCEFILE_OLD"`"
@@ -265,21 +249,21 @@
  [ $? -ne 0 ] && DIR_NEW='/root'
  [ -f ${DIR_NEW}/verytempfilehere ] && rm -f ${DIR_NEW}/verytempfilehere
  #100131 default to using '___' instead of ':'...
  #SOURCEFILE_DELTA="${DIR_NEW}/${BASE_OLD}:${BASE_NEW}.delta"
  SOURCEFILE_DELTA="${DIR_NEW}/${BASE_OLD}___${BASE_NEW}.delta"
- xmessage -bg orange -center -buttons "" "${_M_14:-please wait...}" & #100131
+ xmessage -bg orange -center -buttons "" "$(gettext 'please wait')..." & #100131
  XMPID=$!
  xdelta3 -e -s "$SOURCEFILE_OLD" "$SOURCEFILE_NEW" "$SOURCEFILE_DELTA" 2>/tmp/xdelta_err
+ XFLG=$?
  sync
  kill $XMPID
- [ -f $LOCALES ] && . $LOCALES # load translation file
- if [ $? -eq 0 ];then
-  xmessage -bg green -center "${_M_17:-SUCCESS! $SOURCEFILE_DELTA generated}"
+ if [ $XFLG -eq 0 ];then
+  xmessage -bg green -center "`eval_gettext \"SUCCESS! \\\${SOURCEFILE_DELTA} generated\"`"
  else
-  xmessage -bg red -center "${_M_5:-ERROR! failed to generate the .delta file. Error message:}
+  xmessage -bg red -center "$(gettext 'ERROR! failed to generate the .delta file. Error message:')
 `cat /tmp/xdelta_err`"
  fi
 fi
 
 
 ###END###