#!/bin/sh
#(c) Barry Kauler Feb 2012 bkhome.org
#licence GPL3 refer /usr/share/doc/legal
#the intention of this script is to manage non-english translations of files.
#this is to include shell scripts, xml, .desktop and menu files.
#translation will only be for the current language, and UTF-8 must be enabled.
#120205 first release, handle gettext'ed scripts.
#120206 added internationalization management of menu.
#120206 simplify gui with help buttons.
#120206 add management of menu categories.
#120207 write translations to a folder in /root with full path, write.log, generate tarball.
#120208 support SSS domains. (read comments in /usr/share/sss/menu_strings/menu_strings for more info)
#120208 sync translated sss-file with master sss-file.
#120209 desk_strings domain translates target files in-place, so need workaround when edit TRANSLATION variables in desk_strings.*
#120209 ...ditto for script_strings
#120210 add handling XML files.
#120212 some tweaks.
#120213 rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
#120213 added management of binary executables.
#120214 generate a langpack PET package.
#120215 added management of initrd files (initrd_strings SSS domain).
#120217 small message fixes.
#120217 support poeditor.
#120218 LANG=${ORIGLANG} prefix needed various places. 120219 a few more.
#120220 need 'head -n1' ex: /usr/local/petget/ui_Classic has export TEXTDOMAIN in two places.
#120224 add 'doc_strings' sss domain, for translating entire files (typically documentation files). 120225 improvements.
#120225 checkbox window to select what documentation files to edit. modify edit-complete message.
#120228 sync doc_strings sss file.
#120307 ROX-Filer now translated via /usr/share/doc/nls/ROX-Filer/ROX-Filer.pot
#120308 ROX-Filer .mo files are not in standard location. workaround when intltool-update fails.
#120309 binary executables, option to retain po file for later editing (instead of uncompile mo).
#120313 langpack pet help msg improved.
#120313 langpack pet: offer to find more po, mo, pot and t12s translations.
#120316 scoop up more translations. 120317 L18L: add man pages.
#120216 small mod. to a message.
#120729 L18L: problem gettext'ing zigbert's apps, which have a lot of scripts, but would like to combine into one .pot file.
#120731 revert 120729.
#120731 any script can have a pre-existing .pot file in /usr/share/doc/nls, it will automatically be used instead of generating a .pot file.
#120731 multiple scripts can have the same TEXTDOMAIN. these scripts can be anywhere. a single .pot will be created/edited.
#120926 want to accumulate many .desktop files (not just for installed pkgs), in /usr/share/applications.in.
#121124 edit script_strings.*, 'read -r' so backslash chars are not escapes.
#130502 L18L/BK: stay in a loop if there is an error converting .po to .mo.
#130503 test if .po file changed. 130506 bug fix.
#130503 L18L: rename AppInfo.xml to AppInfo.xml.in for langpack
#130512 acknowledge new translators.
#130526 L18L: intltool-update fails with ROX-Filer and xdialog, but msgmerge works.
#130807 L18L: need sync.

#***MOMANAGER IS ENGLISH ONLY (NOT GETTEXT'ED)***
#it is for use by developers/translators with knowledge of english.

PARAM1=""
[ $1 ] && PARAM1="$1"

ORIGLANG=$LANG
export LANG=C
. /etc/rc.d/PUPSTATE
GTKDIALOGEXE="gtkdialog"
[ "`which gtkdialog4`" ] && GTKDIALOGEXE="gtkdialog4"
mkdir -p /tmp/momanager
ADATE="`date +%Y%m%d`" #ex: 20120205
WINICON="gtk-preferences"; HELPICON="gtk-index" #gtk-info

ORIGLANG1="`echo -n $ORIGLANG | cut -f 1 -d '_'`"  #ex: de
ORIGLANG12="`echo -n $ORIGLANG | cut -f 1 -d '.'`" #ex: de_DE

if [ "$ORIGLANG1" = "en" ];then
 pupdialog --title "MoManager: abort" --background pink --colors --msgbox "This application is intended for creation and editing of non-English translations of scripts, but your locale is currently \Zb${ORIGLANG}\ZB. Click the \Zbsetup\ZB icon on the desktop to change locale (and be sure to enable UTF-8). Aborting." 0 0
 exit 1
fi
if [ "`echo -n $ORIGLANG | grep -i 'utf'`" = "" ];then
 pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, your \Zblocale\ZB (language) must have UTF-8 enabled to use this application. Click the \Zbsetup\ZB icon on the desktop to change locale. Aborting." 0 0
 exit 1
fi
if [ "`which gcc`" = "" ];then
 pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, you must have the \Zbdevx\ZB SFS loaded. Aborting." 0 0
 exit 1
fi
MISSINGFILE=""
[ "`which intltool-update`" = "" ] && MISSINGFILE="intltool-update "
[ "`which xgettext`" = "" ] && MISSINGFILE="${MISSINGFILE}xgettext "
[ "`which msginit`" = "" ] && MISSINGFILE="${MISSINGFILE}msginit "
[ "`which msgfmt`" = "" ] && MISSINGFILE="${MISSINGFILE}msgfmt "
[ "`which msgunfmt`" = "" ] && MISSINGFILE="${MISSINGFILE}msgunfmt "
[ "`which msgmerge`" = "" ] && MISSINGFILE="${MISSINGFILE}msgmerge" #130526
if [ "$MISSINGFILE" ];then
 pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, these needed applications are missing: \Zb${MISSINGFILE}\ZB. The \Zbdevx\ZB SFS normally has these, but it must be incomplete. Aborting." 0 0
 exit 1
fi

POEDITOR="`which poeditor`"
[ ! "$POEDITOR" ] && POEDITOR="`which poedit`"

PATHPREFIX=""
case $PUPMODE in
 2) PATHPREFIX="" ;; #full hd installation.
 3) PATHPREFIX="" ;;
 *) PATHPREFIX="/initrd/pup_ro2" ;;
esac
if [ "$PATHPREFIX" = "" ];then
 pupdialog --title "MoManager: abort" --background pink --msgbox "Sorry, the PUPMODE must be a value greater than 3, that is, not be a full hd installation. Aborting." 0 0
 exit 1
fi
ppPTN="s%${PATHPREFIX}%%"

#download woof, to get latest files... no, too difficult, just put up warning...
export MM1_DLG="<window title=\"MoManager: welcome\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
 <vbox>
  <text><label>Welcome, MoManager will help you to create and edit language translations for your country, for many of the applications in Puppy.</label></text>
  <text><label>VERY IMPORTANT: You must be currently running a Puppy built from the latest version of Woof, or very near latest. If your Puppy is even a month old, it is recommended that you check for a later release -- and be sure that it is built from the latest Woof. You can check my blog (bkhome.org/blog2) for release announcements, or adventurous developers can even download Woof and build their own Puppy (the online Woof repository at bkhome.org/fossil/woof2.cgi has link to instructions)</label></text>
  <text><label>If you are currently running a very recent Woof-built Puppy, then click the 'OK' button to continue running MoManager:</label></text>
  <hbox>
   <button ok></button>
   <button cancel></button>
  </hbox>
 </vbox>
</window>
"
if [ ! "$PARAM1" ];then #on reentry, bypass this window.
 MM1RET="`$GTKDIALOGEXE --program=MM1_DLG`"
 [ "`echo "$MM1RET" | grep 'OK'`" = "" ] && exit 2
fi

yaf-splash -close never -bg orange -text "Please wait, scanning files..." &
yPID=$!

echo -n "" > /tmp/momanager/translations4langpack #to create the langpack PET.
TRANSLANG=""

poptop_func() {
 #passed param $1 is string to display at top of screen, optional $2 is color, $3 is timeout.
 BACKCOL='yellow'
 [ $2 ] && BACKCOL="$2"
 POPTIME='9'
 [ $3 ] && POPTIME="$3"
 echo "#!/bin/sh
 sleep 3
 yaf-splash -bg ${BACKCOL} -placement top -timeout ${POPTIME} -text \"${1}\"
 " > /tmp/momanager/yafmsg9${POPTIME}
 chmod 755 /tmp/momanager/yafmsg9${POPTIME}
 /tmp/momanager/yafmsg9${POPTIME} & #msg has delay so will appear on top of text editor window.
}

#####SCRIPTS#######
#find all gettext'ed scripts...
#GETTEXTSCRIPTS="`find ${PATHPREFIX}/bin ${PATHPREFIX}/sbin ${PATHPREFIX}/usr/bin ${PATHPREFIX}/usr/sbin ${PATHPREFIX}/usr/X11R7/bin ${PATHPREFIX}/usr/local ${PATHPREFIX}/etc/rc.d -maxdepth 4 -type f -executable | xargs -I INPUTFILE grep --files-with-matches '^export TEXTDOMAIN=' INPUTFILE | sed -e 's% %SPACECHAR%g' -e "$ppPTN" | sort | tr '\n' ' '`"
GETTEXTSCRIPTS="`find /bin /sbin /usr/bin /usr/sbin /usr/X11R7/bin /usr/local /etc/rc.d /root/my-applications/bin -maxdepth 4 -type f -executable | xargs -I INPUTFILE grep --files-with-matches '^export TEXTDOMAIN=' INPUTFILE | sed -e 's% %SPACECHAR%g' | sort | tr '\n' ' '`"

#find all matching .mo files...
YESCNT=0; NOCNT=0; YESMO_XML=""; NOMO_XML=""
for AGTS in $GETTEXTSCRIPTS
do
 xAGTS="`echo -n $AGTS | sed -e 's%SPACECHAR% %g'`"
 #120731 what if code is: export TEXTDOMAIN='abc' or export TEXTDOMAIN="abc" remove the quotes... NO, not allowed to have quotes!!!!
 TEXTDOMAINVALUE="`grep '^export TEXTDOMAIN=' "$xAGTS" | head -n 1 | cut -f 2 -d '=' | tr '\t' ' ' | cut -f 1 -d ' '`" #1202120 need 'head -n1' ex: /usr/local/petget/ui_Classic has export TEXTDOMAIN in two places.

 #want to know if from Woof or a builtin pkg or later-installed pkg...
 BASExAGTS="`basename "$xAGTS"`"
 xPTN=" ${BASExAGTS}$"
 PATHxAGTS="`dirname "$xAGTS"`"
 xxPTN="^${PATHxAGTS}$"
 zPTN="^${xAGTS}$"
 aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
 if [ "$aPKGNAME" ];then #confirm full path.
  for AAA in $aPKGNAME
  do
   CONFIRM="`cat /root/.packages/builtin_files/${AAA} | sed -e 's%^ %/%' | tr -d '\n' | grep "$xAGTS"`"
   if [ "$CONFIRM" ];then
    aPKGNAME="$AAA"
    break
   fi
  done
  [ ! "$CONFIRM" ] && aPKGNAME=""
 fi
 [ ! "$aPKGNAME" ] && aPKGNAME="`grep "$zPTN" /root/.packages/*.files 2>/dev/null | head -n 1 | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev | sed -e 's%\.files$%%'`" #test if user-installed pkg. 120308
 #...return nothing if in Woof
 [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${xAGTS}" ] && aPKGNAME="WOOF" #file is in Woof.
 [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"

 FNDMO=""
 if [ -f /usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
  FNDMO="/usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
  TRANSLANG=$ORIGLANG12
 else
  if [ -f /usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
   FNDMO="/usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
   TRANSLANG=$ORIGLANG1
  fi
 fi
 if [ "$FNDMO" ];then
  YESCNT=$(($YESCNT + 1))
  YESMO_XML="${YESMO_XML}
<item>${xAGTS} (${TRANSLANG} ${TEXTDOMAINVALUE}.mo ${aPKGNAME})</item>"
  echo "$FNDMO" >> /tmp/momanager/translations4langpack
 else
  NOCNT=$(($NOCNT + 1))
#  NOMO_XML="${NOMO_XML}
#<radiobutton><variable>NORAD${NOCNT}</variable><label>${xAGTS}</label></radiobutton>"
  NOMO_XML="${NOMO_XML}
<item>${xAGTS} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>"
 fi
done
if [ "$YESMO_XML" ];then
 YESMO_XML="<combobox width-request=\"310\"><variable>YESMO_COMBO</variable>${YESMO_XML}</combobox>"
else
 #YESMO_XML="<text><label>nothing</label></text>"
 YESMO_XML="<combobox width-request=\"310\"><variable>EMPTYYESMO_COMBO</variable><item>--empty--</item></combobox>"
fi
if [ "$NOMO_XML" ];then
 NOMO_XML="<combobox width-request=\"330\"><variable>NOMO_COMBO</variable>${NOMO_XML}</combobox>"
else
 #NOMO_XML="<text><label>nothing</label></text>"
 NOMO_XML="<combobox width-request=\"330\"><variable>EMPTYNOMO_COMBO</variable><item>--empty--</item></combobox>"
fi

#######MENU ENTRIES#######
#find out which .desktop files have [lang] entries already, create two lists...
YESDESK_XML=""; NODESK_XML=""
dPTN="\\[${ORIGLANG1}\\]"
for ADESKTOP in `find /usr/share/applications -mindepth 1 -maxdepth 1 -type f -name '*.desktop' | grep -v ' ' | sort | tr '\n' ' '`
do
 [ "`grep '^Icon' $ADESKTOP`" = "" ] && continue #some dummy .desktop files used by xfce, ignore them.
 ADESKNAME="`basename $ADESKTOP`"
 
 #find out what package it is from...
 xPTN=" ${ADESKNAME}$"
 zPTN="^${ADESKTOP}$"
 aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | head -n 1 | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
 [ ! "$aPKGNAME" ] && aPKGNAME="`grep "$zPTN" /root/.packages/*.files 2>/dev/null | head -n 1 | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev | sed -e 's%\.files$%%'`" #test if user-installed pkg. 120308
 #...return nothing if in Woof
 [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${ADESKTOP}" ] && aPKGNAME="WOOF" #file is in Woof.
 [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
 
 if [ "`grep "$dPTN" $ADESKTOP`" != "" ];then
  YESDESK_XML="${YESDESK_XML}
<item>${ADESKNAME} (${aPKGNAME})</item>"
  echo "$ADESKTOP" >> /tmp/momanager/translations4langpack
 else
  NODESK_XML="${NODESK_XML}
<item>${ADESKNAME} (${aPKGNAME})</item>"
 fi
done
if [ "$YESDESK_XML" ];then
 YESDESK_XML="<combobox width-request=\"310\"><variable>YESDESK_COMBO</variable>${YESDESK_XML}</combobox>"
else
 #YESDESK_XML="<text><label>nothing</label></text>"
 YESDESK_XML="<combobox width-request=\"310\"><variable>EMPTYYESDESK_COMBO</variable><item>--empty--</item></combobox>"
fi
if [ "$NODESK_XML" ];then
 NODESK_XML="<combobox width-request=\"330\"><variable>NODESK_COMBO</variable>${NODESK_XML}</combobox>"
else
 #NODESK_XML="<text><label>nothing</label></text>"
 NODESK_XML="<combobox width-request=\"330\"><variable>EMPTYNODESK_COMBO</variable><item>--empty--</item></combobox>"
fi

#help buttons...
YESMO_HELP_MSG="Puppy has many <b>scripts</b>, applications that are plain text files, usually written in Bash or Ash. These scripts all have English capability, but language translation files may be created for them, known as <b>mo</b> files.
The drop-down list is a list of scripts for which there is a mo translation file in your language.
The drop-down list has extra information in brackets, in the format <b>(lang TEXTDOMAIN package)</b>. In particular, package=WOOF means the file is in Woof, or the name of the package from which the file comes is given, or if not known then package=UNKNOWN.
A mo translation file in your language (${ORIGLANG12}) is at /usr/share/locale/${ORIGLANG12}/LC_MESSAGES/ or /usr/share/locale/${ORIGLANG1}/LC_MESSAGES/. You may select one of the scripts, then click the <b>Edit</b> button to update it.
Updating is required if the translation is incorrect or incomplete in any way. One reason this can happen is if there is a later version of the script with some changed English text strings."
export DLG_HELP_YESMO="<window resizable=\"false\" title=\"MoManager: Help edit mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESMO_HELP_MSG}\"</label><variable>VAR_HELP_YESMO</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESMO</action></button></hbox></vbox></window>"
YESMOHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESMO</action></button>'

NOMO_HELP_MSG="Puppy has many <b>scripts</b>, applications that are plain text files, usually written in Bash or Ash. These scripts all have English capability, but language translation files may be created for them, known as <b>mo</b> files.
The drop-down list is a list of scripts for which there is no mo translation file in your language.
The drop-down list has extra information in brackets, in the format <b>(TEXTDOMAIN package)</b>. In particular, package=WOOF means the file is in Woof, or the name of the package from which the file comes is given, or if not known then package=UNKNOWN.
To create a translation file, select a script from the list, then click the <b>Create</b> button. This will open a file in a text editor which has all the English strings from the script, and below each you type in your translations. This file is known as a <b>po</b> file, and after saving and quiting the text editor, the file will be compiled into a binary format known as a <b>mo</b> file -- note, po files have a filename ending in .po and mo files end in .mo. It is the mo file that the script will use when it runs."
export DLG_HELP_NOMO="<window resizable=\"false\" title=\"MoManager: Help create mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NOMO_HELP_MSG}\"</label><variable>VAR_HELP_NOMO</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOMO</action></button></hbox></vbox></window>"
NOMOHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOMO</action></button>'

YESDESK_HELP_MSG="The drop-down list is of .desktop files in /usr/share/applications, that have translations for your language.
The <b>Name[${ORIGLANG1}]</b> entry in these files is what you see when you click on the Menu button at bottom-left of the screen (in some puppies the menu button is placed elsewhere). There will be a translation for each application.
If you need to correct an entry, select the appropriate .desktop file, then click the <b>Edit</b> button.
Note, The drop-down list has extra information in brackets, which is the name of the package that the file belongs to. <b>WOOF</b> means that the file is in Woof."
export DLG_HELP_YESDESK="<window resizable=\"false\" title=\"MoManager: Help edit menu entries\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESDESK_HELP_MSG}\"</label><variable>VAR_HELP_YESDESK</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESDESK</action></button></hbox></vbox></window>"
YESDESKHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESDESK</action></button>'

NODESK_HELP_MSG="The drop-down list is of .desktop files in /usr/share/applications, that do <i>not</i> have translations for your language.
The <b>Name[${ORIGLANG1}]</b> entry in these files is what you see when you click on the Menu button at bottom-left of the screen (in some puppies the menu button is placed elsewhere). There will be a translation for each application, but for these .desktop files there is no translation, so the entries will display in English.
If you wish to create a translation, select the appropriate .desktop file, then click the <b>Create</b> button.
Note, The drop-down list has extra information in brackets, which is the name of the package that the file belongs to. <b>WOOF</b> means that the file is in Woof."
export DLG_HELP_NODESK="<window resizable=\"false\" title=\"MoManager: Help create menu entries\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NODESK_HELP_MSG}\"</label><variable>VAR_HELP_NODESK</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NODESK</action></button></hbox></vbox></window>"
NODESKHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NODESK</action></button>'

#######MENU TITLES#######
#this gives us the list of .directory files in /usr/share/desktop-directories for the top-level titles... ex: Puppy-Setup.directory
TOPMENUFILES="`grep -m1 '<Directory>' /etc/xdg/menus/puppy-[^S]*.menu | cut -f 2 -d '>' | cut -f 1 -d '<' | grep 'directory$' | sort | tr '\n' ' '`"
YESTOP_XML=""; NOTOP_XML=""
dPTN="^Name\\[${ORIGLANG1}\\]"
for ATOPMENUFILE in $TOPMENUFILES
do
 if [ "`grep "$dPTN" /usr/share/desktop-directories/$ATOPMENUFILE`" != "" ];then
  #there is already a translation.
  YESTOP_XML="${YESTOP_XML}
<item>${ATOPMENUFILE}</item>"
  echo "/usr/share/desktop-directories/${ATOPMENUFILE}" >> /tmp/momanager/translations4langpack
 else
  NOTOP_XML="${NOTOP_XML}
<item>${ATOPMENUFILE}</item>"
 fi
done
if [ "$YESTOP_XML" ];then
 YESTOP_XML="<combobox width-request=\"310\"><variable>YESTOP_COMBO</variable>${YESTOP_XML}</combobox>"
else
 #YESTOP_XML="<text><label>nothing</label></text>"
 YESTOP_XML="<combobox width-request=\"310\"><variable>EMPTYYESTOP_COMBO</variable><item>--empty--</item></combobox>"
fi
if [ "$NOTOP_XML" ];then
 NOTOP_XML="<combobox width-request=\"330\"><variable>NOTOP_COMBO</variable>${NOTOP_XML}</combobox>"
else
 #NOTOP_XML="<text><label>nothing</label></text>"
 NOTOP_XML="<combobox width-request=\"330\"><variable>EMPTYNOTOP_COMBO</variable><item>--empty--</item></combobox>"
fi
#help buttons...
YESTOP_HELP_MSG="These are the top-level menu titles, or categories, that you see when you click on the 'Menu' button at bottom-left of the screen (or elsewhere in some puppies). The drop-down list is for those categories that already have a translation for the <b>${ORIGLANG1}</b> locale.
If you wish to change a translation, select a file from the drop-down list, then click the <b>Edit</b> button. A text editor will open, then edit the <b>Name[${ORIGLANG1}]</b> entry, then save and quit the editor. Afterward, the menu will refresh and you will be able to see the change."
export DLG_HELP_YESTOP="<window resizable=\"false\" title=\"MoManager: Help edit menu categories\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESTOP_HELP_MSG}\"</label><variable>VAR_HELP_YESTOP</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESTOP</action></button></hbox></vbox></window>"
YESTOPHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESTOP</action></button>'
NOTOP_HELP_MSG="These are the top-level menu titles, or categories, that you see when you click on the 'Menu' button at bottom-left of the screen (or elsewhere in some puppies). The drop-down list is for those categories that do <i>not</i> have a translation for the <b>${ORIGLANG1}</b> locale (so they will display in English).
If you wish to create a translation, select a file from the drop-down list, click the <b>Create</b> button. A text editor will open, then edit the <b>Name[${ORIGLANG1}]</b> entry, then save and quit the editor. Afterward, the menu will refresh and you will be able to see the change."
export DLG_HELP_NOTOP="<window resizable=\"false\" title=\"MoManager: Help edit menu categories\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NOTOP_HELP_MSG}\"</label><variable>VAR_HELP_NOTOP</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOTOP</action></button></hbox></vbox></window>"
NOTOPHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOTOP</action></button>'

#######XML#######
#search $PATHPREFIX to avoid devx files...
YESXML_XML='' ; NOXML_XML=''
#XMLFILES="`find ${PATHPREFIX}/usr/local -type f -name '*.xml' | sed "s%^${PATHPREFIX}%%" | sed -e 's% %SPACECHAR%g' | tr '\n' ' '`" #ex: /usr/local/apps/Connect/AppInfo.xml
XMLFILES="`find /usr/local -type f -name '*.xml' | sed -e 's% %SPACECHAR%g' | tr '\n' ' '`" #ex: /usr/local/apps/Connect/AppInfo.xml
aPTN="xml:lang=\"${ORIGLANG1}\""  #ex: xml:lang="de"
bPTN="xml:lang=\"${ORIGLANG12}\"" #ex: xml:lang="de_DE"
for AXMLFILE in $XMLFILES
do
 AXMLFILE="`echo -n "$AXMLFILE" | sed -e 's%SPACECHAR% %g'`"
 
 #[ "`echo -n "$AXMLFILE" | grep 'apps/ROX-Filer/'`" != "" ] && continue #120307 ROX-Filer now translated via /usr/share/doc/nls/ROX-Filer/ROX-Filer.pot
 #120308 ...no, we still need to edit this, see User Manual.
 
 #want to know if from Woof or a builtin pkg or later-installed pkg...
 BASEAXMLFILE="`basename "$AXMLFILE"`"
 xPTN=" ${BASEAXMLFILE}$"
 PATHAXMLFILE="`dirname "$AXMLFILE"`"
 xxPTN="^${PATHAXMLFILE}$"
 zPTN="^${AXMLFILE}$"
 aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
 if [ "$aPKGNAME" ];then #confirm full path.
  for AAA in $aPKGNAME
  do
   CONFIRM="`cat /root/.packages/builtin_files/${AAA} | sed -e 's%^ %/%' | tr -d '\n' | grep "$AXMLFILE"`"
   if [ "$CONFIRM" ];then
    aPKGNAME="$AAA"
    break
   fi
  done
  [ ! "$CONFIRM" ] && aPKGNAME=""
 fi
 [ ! "$aPKGNAME" ] && aPKGNAME="`grep "$zPTN" /root/.packages/*.files 2>/dev/null | head -n 1 | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev | sed -e 's%\.files$%%'`" #test if user-installed pkg. 120308
 #...return nothing if in Woof
 [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${AXMLFILE}" ] && aPKGNAME="WOOF" #file is in Woof.
 [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
 
 FNDFLAG=''
 FNDFLAG="`grep "$aPTN" "$AXMLFILE"`"
 [ ! "$FNDFLAG" ] && FNDFLAG="`grep "$bPTN" "$AXMLFILE"`"
 if [ "$FNDFLAG" ];then
  #there is already a translation.
  YESXML_XML="${YESXML_XML}
<item>${AXMLFILE} (${aPKGNAME})</item>"
  echo "${AXMLFILE}" >> /tmp/momanager/translations4langpack
 else
  NOXML_XML="${NOXML_XML}
<item>${AXMLFILE} (${aPKGNAME})</item>"
 fi
done
if [ "$YESXML_XML" ];then
 YESXML_XML="<combobox width-request=\"310\"><variable>YESXML_COMBO</variable>${YESXML_XML}</combobox>"
else
 YESXML_XML="<combobox width-request=\"310\"><variable>EMPTYYESXML_COMBO</variable><item>--empty--</item></combobox>"
fi
if [ "$NOXML_XML" ];then
 NOXML_XML="<combobox width-request=\"330\"><variable>NOXML_COMBO</variable>${NOXML_XML}</combobox>"
else
 NOXML_XML="<combobox width-request=\"330\"><variable>EMPTYNOXML_COMBO</variable><item>--empty--</item></combobox>"
fi
#help buttons...
XML_COM_HELP="XML files are a form of structured data that applications (such as ROX-Filer) may use, and they may contain text that the application displays on-screen. The XML specification has a standard notation for text strings in different languages, using the <b>xml:lang</b> attribute. For example:

 &lt;Label&gt;Connect to the Internet now&lt;/Label&gt;
 &lt;Label xml:lang="ru"&gt;Подключиться к Интернет сейчас&lt;/Label&gt;
 &lt;Label xml:lang="ja"&gt;インターネット接続ウィザードを実行&lt;/Label&gt;
 &lt;Label xml:lang="zh_CN"&gt;运行互联网连接向导&lt;/Label&gt;"
YESXML_HELP_MSG="${XML_COM_HELP}

The XML files in the drop-down list already have xml:lang translations for your <b>${ORIGLANG12}</b> locale, however they might not be correct or complete so should be reviewed. Please select a file, then click the <b>Edit</b> button.
Note, the brackets alongside each filename in the drop-down list contains the name of the package that the file comes from -- WOOF means that the file comes from Woof."
export DLG_HELP_YESXML="<window resizable=\"false\" title=\"MoManager: Help edit XML files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\" width-chars=\"70\"><label>\"${YESXML_HELP_MSG}\"</label><variable>VAR_HELP_YESXML</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESXML</action></button></hbox></vbox></window>"
YESXMLHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESXML</action></button>'
NOXML_HELP_MSG="${XML_COM_HELP}

The XML files in the drop-down list do <i>not</i> have xml:lang translations for your <b>${ORIGLANG12}</b> locale. You will need to determine where the translations are to be inserted. Please select a file, then click the <b>Create</b> button.
Note, the brackets alongside each filename in the drop-down list contains the name of the package that the file comes from -- WOOF means that the file comes from Woof."
export DLG_HELP_NOXML="<window resizable=\"false\" title=\"MoManager: Help edit XML files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\" width-chars=\"70\"><label>\"${NOXML_HELP_MSG}\"</label><variable>VAR_HELP_NOXML</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOXML</action></button></hbox></vbox></window>"
NOXMLHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOXML</action></button>'

#######SSS#######
#Simple String Substitution
#manage translations in many non-executable data files.
#translations are kept in /usr/share/sss/$SSSDOMAIN/$SSSDOMAIN.$ORIGLANG1 ex: SSSDOMAIN=menu_strings ORIGLANG1=de
YESSSS_XML=""; NOSSS_XML=""
for ASSSDOMAIN in `find /usr/share/sss -mindepth 1 -maxdepth 1 -type d | sed -e 's%^/usr/share/sss/%%' | tr '\n' ' '`
do

 #120224 doc_strings is a special case, the translated file is elsewhere...
 if [ -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} ];then
  if [ "$ASSSDOMAIN" = "doc_strings" ];then
   cp -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN} /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} #120228 must always be same as orig.
   TRANSFLAG='fail'
   TRANSLATEDFILES="`grep '^SSS_TRANSLATION_RULE' /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} | cut -f 2 -d "'" | sed -e "s%SSSLANG1MARKER%${ORIGLANG1}%" | tr '\n' ' '`" #'geanyfix
   for ATRANSLATEDFILE in $TRANSLATEDFILES
   do
    if [ -f $ATRANSLATEDFILE ];then
     echo "$ATRANSLATEDFILE" >> /tmp/momanager/translations4langpack
     TRANSFLAG='success'
    fi
   done
   [ "$TRANSFLAG" = "fail" ] && rm -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} #because translated file(s) does not exist.
  fi
 fi

 if [ -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} ];then
  #there is already a translation.
  YESSSS_XML="${YESSSS_XML}
<item>${ASSSDOMAIN}.${ORIGLANG1}</item>"
  echo "/usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1}" >> /tmp/momanager/translations4langpack
 else
  NOSSS_XML="${NOSSS_XML}
<item>${ASSSDOMAIN}</item>"
 fi
done
if [ "$YESSSS_XML" ];then
 YESSSS_XML="<combobox width-request=\"310\"><variable>YESSSS_COMBO</variable>${YESSSS_XML}</combobox>"
else
 YESSSS_XML="<combobox width-request=\"310\"><variable>EMPTYYESSSS_COMBO</variable><item>--empty--</item></combobox>"
fi
if [ "$NOSSS_XML" ];then
 NOSSS_XML="<combobox width-request=\"330\"><variable>NOSSS_COMBO</variable>${NOSSS_XML}</combobox>"
else
 NOSSS_XML="<combobox width-request=\"330\"><variable>EMPTYNOSSS_COMBO</variable><item>--empty--</item></combobox>"
fi
#help buttons...
SSS_DOMAINS_MSG="
<b>menu_strings</b>
These are translations for window manager and tray data files. For example, the JWM window manager has a data file /root/.jwmrc, which has some strings that appear in on-screen menus (apart from the main application menu).

<b>desk_strings</b>
These are translations for any text data-files that have some text that displays on-screen.

<b>script_strings</b>
These are translations for scripts. The SSS method works on original scripts (in any language, ex: Bash, Lua, Perl, Tcl), whereas the gettext and t12s methods require editing of the script (however, gettext is a much more powerful translation technique).

<b>initrd_strings</b>
These are translations for files in the initrd (also known as the initramfs). This is a bit different from the other SSS domains, as the target files are translated at bootup, every bootup.

<b>doc_strings</b>
This is totally different from all the above, as translations are made of entire files, using a suitable editor -- this is typically documentation files."
YESSSS_HELP_MSG="<b>SSS</b> means Simple String Substitution, a simple method of language translation for any type of text files. Files are translated in-place, that is, the original English files are replaced by the translated files -- this is translation <i>before</i> execution, as opposed to gettext which is run-time translation. An <b>SSS domain</b> defines a class of files that need to be translated. The drop-down list contains domains that have <b>${ORIGLANG1}</b> translations, however do check them as the translations may be incomplete. The headings below are the various domains:
${SSS_DOMAINS_MSG}"
export DLG_HELP_YESSSS="<window resizable=\"false\" title=\"MoManager: Help edit SSS domains\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESSSS_HELP_MSG}\"</label><variable>VAR_HELP_YESSSS</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESSSS</action></button></hbox></vbox></window>"
YESSSSHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESSSS</action></button>'
NOSSS_HELP_MSG="<b>SSS</b> means Simple String Substitution, a simple method of language translation for any type of text files. Files are translated in-place, that is, the original English files are replaced by the translated files -- this is translation <i>before</i> execution, as opposed to gettext which is run-time translation. An <b>SSS domain</b> defines a class of files that need to be translated. The drop-down list contains domains that do <i>not</i> have <b>${ORIGLANG1}</b> translations (so any on-screen text will be in English). The headings below are the various domains:
${SSS_DOMAINS_MSG}"
export DLG_HELP_NOSSS="<window resizable=\"false\" title=\"MoManager: Help create SSS domains\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NOSSS_HELP_MSG}\"</label><variable>VAR_HELP_NOSSS</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOSSS</action></button></hbox></vbox></window>"
NOSSSHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOSSS</action></button>'

########Binary executables#######
#support a limited number of binary executables that have .pot files in /usr/share/doc/nls
YESCNT=0 ; NOCNT=0 ; YESBIN_XML="" ; NOBIN_XML=""
for ANLSDIR in `ls -1 /usr/share/doc/nls | tr '\n' ' '`
do
 if [ -d  /usr/share/doc/nls/${ANLSDIR} ];then
 
  #120309 po files may now be there... ex: /usr/share/doc/nls/ROX-Filer/de.po
  FNDPO="`find /usr/share/doc/nls/${ANLSDIR} -mindepth 1 -maxdepth 1 -type f -name '*.po' | tr '\n' ' '`"
  for APO in $FNDPO
  do
   echo "$APO" >> /tmp/momanager/translations4langpack
  done
 
  BINEXEC=""
  BINEXEC="`which $ANLSDIR`"
  [ ! "$BINEXEC" ] && BINEXEC="`find /usr/local -maxdepth 4 -executable -type f -name "$ANLSDIR"`" #ex: /usr/local/simple_network_setup/proxy-setup
  if [ "$BINEXEC" ];then
   if [ "`file "$BINEXEC" | grep ' ELF ' | grep 'LSB executable'`" != "" ];then
    #have found binary executable for the pot file...
    TEXTDOMAINVALUE="$ANLSDIR" #TEXTDOMAIN must be same as executable name.
    
    #want to know if from Woof or a builtin pkg or later-installed pkg...
    BASEBINEXEC="`basename "$BINEXEC"`"
    xPTN=" ${BASEBINEXEC}$"
    PATHBINEXEC="`dirname "$BINEXEC"`"
    xxPTN="^${PATHBINEXEC}$"
    zPTN="^${BINEXEC}$"
    aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
    if [ "$aPKGNAME" ];then #confirm full path.
     for AAA in $aPKGNAME
     do
      CONFIRM="`cat /root/.packages/builtin_files/${AAA} | sed -e 's%^ %/%' | tr -d '\n' | grep "$BINEXEC"`"
      if [ "$CONFIRM" ];then
       aPKGNAME="$AAA"
       break
      fi
     done
     [ ! "$CONFIRM" ] && aPKGNAME=""
    fi
    [ ! "$aPKGNAME" ] && aPKGNAME="`grep "$zPTN" /root/.packages/*.files 2>/dev/null | head -n 1 | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev | sed -e 's%\.files$%%'`" #test if user-installed pkg. 120308
    #...return nothing if in Woof
    [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${BINEXEC}" ] && aPKGNAME="WOOF" #file is in Woof.
    [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
    
    FNDMO=""
    PREFIXLOCALEDIR='/usr/share/locale' #120308
    if [ -f /usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
     FNDMO="/usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
     TRANSLANG=$ORIGLANG12
    else
     if [ -f /usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
      FNDMO="/usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
      TRANSLANG=$ORIGLANG1
     fi
    fi
    #120308 ROX-Filer is example where .mo is elsewhere. search all roxapps..
    if [ ! "$FNDMO" ];then
     FNDMO="`find /usr/local/apps -type f -name "${TEXTDOMAINVALUE}.mo"`"
     TRANSLANG=$ORIGLANG1
     PREFIXLOCALEDIR="`echo -n "$FNDMO" | sed -e 's%/LC_MESSAGES.*%%' | rev | cut -f 2-9 -d '/' | rev`" #ex: /usr/local/apps/ROX-Filer/Messages/de/LC_MESSAGES/ROX-Filer.mo, extract /usr/local/apps/ROX-Filer/Messages
    fi
    if [ "$FNDMO" ];then
     YESCNT=$(($YESCNT + 1))
     YESBIN_XML="${YESBIN_XML}
<item>${BINEXEC} (${TRANSLANG} ${TEXTDOMAINVALUE}.mo ${aPKGNAME})</item>"
     echo "${PREFIXLOCALEDIR}/${TRANSLANG}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo" >> /tmp/momanager/translations4langpack #120308
    else
     NOCNT=$(($NOCNT + 1))
     NOBIN_XML="${NOBIN_XML}
<item>${BINEXEC} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>"
    fi
    
   fi
  fi
 fi
done
if [ "$YESBIN_XML" ];then
 YESBIN_XML="<combobox width-request=\"310\"><variable>YESBIN_COMBO</variable>${YESBIN_XML}</combobox>"
else
 YESBIN_XML="<combobox width-request=\"310\"><variable>EMPTYYESBIN_COMBO</variable><item>--empty--</item></combobox>"
fi
if [ "$NOBIN_XML" ];then
 NOBIN_XML="<combobox width-request=\"330\"><variable>NOBIN_COMBO</variable>${NOBIN_XML}</combobox>"
else
 NOBIN_XML="<combobox width-request=\"330\"><variable>EMPTYNOBIN_COMBO</variable><item>--empty--</item></combobox>"
fi
#help buttons...
YESBIN_HELP_MSG="MoManager provides translation support for a limited number of binary executables. These are executables in Woof or in PET packages, that have <b>pot</b> files at /usr/share/doc/nls. The drop-down list is of binary executables that already have a ${ORIGLANG1} or ${ORIGLANG12} translation, but you may wish to review the translations, especially if the version of the binary executable has changed. Select a file, then click the <b>Edit</b> button.

The drop-down list has extra information in brackets, in the format <b>(lang TEXTDOMAIN package)</b>. In particular, package=WOOF means the file is in Woof, or the name of the package from which the file comes is given, or if not known then package=UNKNOWN.

A <b>pot</b> file is a translation template file. MoManager converts it to a <b>po</b> file, which is an editable form for your language, and it is finally compiled to a <b>mo</b> file and placed at /usr/share/locale.

There are many other binary executable applications in Puppy that are not managed by MoManager. For those, for example the Abiword word processor, the author of the application provides translations. In many cases you can find a nls translation package for an application via the Puppy Package Manager."
export DLG_HELP_YESBIN="<window resizable=\"false\" title=\"MoManager: Help edit mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESBIN_HELP_MSG}\"</label><variable>VAR_HELP_YESBIN</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESBIN</action></button></hbox></vbox></window>"
YESBINHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESBIN</action></button>'
NOBIN_HELP_MSG="MoManager provides translation support for a limited number of binary executables. These are executables in Woof or in PET packages, that have <b>pot</b> files at /usr/share/doc/nls. The drop-down list is of binary executables that do <i>not</i> have a ${ORIGLANG1} or ${ORIGLANG12} translation. To create one, select a file, then click the <b>Create</b> button.

The drop-down list has extra information in brackets, in the format <b>(TEXTDOMAIN package)</b>. In particular, package=WOOF means the file is in Woof, or the name of the package from which the file comes is given, or if not known then package=UNKNOWN.

A <b>pot</b> file is a translation template file. MoManager converts it to a <b>po</b> file, which is an editable form for your language, and it is finally compiled to a <b>mo</b> file and placed at /usr/share/locale.

There are many other binary executable applications in Puppy that are not managed by MoManager. For those, for example the Abiword word processor, the author of the application provides translations. In many cases you can find a nls translation package for an application via the Puppy Package Manager."
export DLG_HELP_NOBIN="<window resizable=\"false\" title=\"MoManager: Help create mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NOBIN_HELP_MSG}\"</label><variable>VAR_HELP_NOBIN</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOBIN</action></button></hbox></vbox></window>"
NOBINHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOBIN</action></button>'

######langpack PET#####
#help button for PET langpack...
GENLANG="$ORIGLANG1"
[ "$TRANSLANG" ] && GENLANG="$TRANSLANG"
PET_HELP_MSG="When you create or edit a translation file in MoManager, it gets put into a tarball, ready for you to email to the author of the application. However, if someone, such as yourself, would like to be maintainer of <b>${ORIGLANG12}</b> translations for Puppy, this would be a great help -- having one guy that we know looks after translations for that language.

As maintainer of ${ORIGLANG12} translations, if you click the <b>PET button</b> in the main window of MoManager, a <b>langpack</b> PET package will be created with all of the translations. Then, all that you have to do is send it to me (Barry Kauler) so that I can upload it to the official noarch PET repository at ibiblio.org.

This will be extremely easy to update. Whenever you have added new translations, or edited existing ones, just click the PET button, and a new langpack PET package will be created. It will have a name like <b>langpack_${GENLANG}-${ADATE}.pet</b>, and be in the /root folder (as well as an expanded directory so that you can see what is in it). Then just send it to me, at <b>bkauler@gmail.com</b>.

We already have coordinators for some langpacks. The names are as they are known on the Puppy Forum. If you want to contribute any changes for these languages, please send them to these guys:
Danish (da):  maans
German (de):  L18L
Greek (el):   kounelii
French (fr):  esmourguit
Italian (it): vicmz (temporary)
Dutch  (nl):  Bert
Polish (pl):  robwoj44
Portuguese (pt): vicmz
Russian (ru): rodin.s
Spanish (es): vicmz"
export DLG_HELP_PET="<window resizable=\"false\" title=\"MoManager: Help langpack PET\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${PET_HELP_MSG}\"</label><variable>VAR_HELP_PET</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_PET</action></button></hbox></vbox></window>"
PETHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_PET</action></button>'




POEDIT_XML=""; POEDIT_CHECK='false'
if [ "$POEDITOR" ];then
 [ -e /var/local/poedit_check ] && POEDIT_CHECK='true'
 POEDIT_XML="<checkbox><label>Tick to use poedit (instead of text editor)</label><default>${POEDIT_CHECK}</default><variable>POCHECK</variable></checkbox> <text><label>\"    \"</label></text>"
fi

export MM2_DLG="<window title=\"MoManager: Puppy files\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
 <vbox>
 
  <text use-markup=\"true\" width-chars=\"86\"><label>\"<big>Welcome! To fully translate Puppy to your <b>${ORIGLANG12}</b> locale, you need to get all of the files on the right-side drop-down lists over to the left-side lists. Simple! Click the help buttons for explanation about each list...</big>\"</label></text>

  <frame Scripts>
  <hbox>
   <vbox>
    <frame Scripts that have a mo file>
     <hbox>${YESMO_XML}<button><label>Edit</label><action>EXIT:edit_mo</action></button>${YESMOHELP_XML}</hbox>
    </frame>
   </vbox>
   <vbox>
    <frame Scripts that do not have a mo file>
     <hbox>${NOMO_XML}<button><label>Create</label><action>EXIT:create_mo</action></button>${NOMOHELP_XML}</hbox>
    </frame>
   </vbox>
  </hbox>
  </frame>
  
  <frame Menu categories>
   <hbox>
    <vbox>
     <frame Menu categories with a ${ORIGLANG1} translation>
      <hbox>${YESTOP_XML}<button><label>Edit</label><action>EXIT:edit_top</action></button>${YESTOPHELP_XML}</hbox>
     </frame>
    </vbox>
    <vbox>
     <frame Menu categories without a ${ORIGLANG1} translation>
     <hbox>${NOTOP_XML}<button><label>Create</label><action>EXIT:create_top</action></button>${NOTOPHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
  </frame>
  
  <frame Menu entries>
   <hbox>
    <vbox>
     <frame Menu entries with a ${ORIGLANG1} translation>
      <hbox>${YESDESK_XML}<button><label>Edit</label><action>EXIT:edit_desk</action></button>${YESDESKHELP_XML}</hbox>
     </frame>
    </vbox>
    <vbox>
     <frame Menu entries without a ${ORIGLANG1} translation>
     <hbox>${NODESK_XML}<button><label>Create</label><action>EXIT:create_desk</action></button>${NODESKHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
  </frame>
  
  <frame XML files>
   <hbox>
    <vbox>
     <frame XML files with a ${ORIGLANG1} translation>
      <hbox>${YESXML_XML}<button><label>Edit</label><action>EXIT:edit_xml</action></button>${YESXMLHELP_XML}</hbox>
     </frame>
    </vbox>
    <vbox>
     <frame XML files without a ${ORIGLANG1} translation>
     <hbox>${NOXML_XML}<button><label>Create</label><action>EXIT:create_xml</action></button>${NOXMLHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
  </frame>
  
  <frame SSS domains>
   <hbox>
    <vbox>
     <frame SSS domains with a ${ORIGLANG1} translation>
      <hbox>${YESSSS_XML}<button><label>Edit</label><action>EXIT:edit_sss</action></button>${YESSSSHELP_XML}</hbox>
     </frame>
    </vbox>
    <vbox>
     <frame SSS domains without a ${ORIGLANG1} translation>
     <hbox>${NOSSS_XML}<button><label>Create</label><action>EXIT:create_sss</action></button>${NOSSSHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
  </frame>

  <frame Binary executables>
   <hbox>
    <vbox>
     <frame Binary executables that have a mo file>
      <hbox>${YESBIN_XML}<button><label>Edit</label><action>EXIT:edit_bin</action></button>${YESBINHELP_XML}</hbox>
     </frame>
    </vbox>
    <vbox>
     <frame Binary executables that do not have a mo file>
     <hbox>${NOBIN_XML}<button><label>Create</label><action>EXIT:create_bin</action></button>${NOBINHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
  </frame>
  
  
  <hbox>
   ${POEDIT_XML}
   <text><label>Create a langpack PET:</label></text>
   <button><input file>/usr/local/lib/X11/mini-icons/pet16.xpm</input><action>EXIT:create_pet</action></button>
   ${PETHELP_XML}
   <text><label>\"                 \"</label></text>
   <button><label>About</label><action>pupdialog --background '#8080FF' --backtitle 'MoManager: About' --msgbox 'Created by Barry Kauler for Puppy Linux. (c) Copyright Barry Kauler 2012, license GPL3 (refer /usr/share/doc/legal)' 0 0 & </action></button>
   <button><label>Exit</label><action>EXIT:quit</action></button>
  </hbox>
  
 </vbox>
</window>
"
#echo "$MM2_DLG" > /tmp/xxx #TEST
kill $yPID

MM1RET="`$GTKDIALOGEXE --program=MM2_DLG`"
eval "$MM1RET"

if [ "$POEDITOR" ];then
 if [ "$POCHECK" = "true" ];then
  touch /var/local/poedit_check
 else
  rm -f /var/local/poedit_check 2>/dev/null
  POEDITOR=""
 fi
fi

tarball_func() {
TARBALLMSG="Translation files that you have created with MoManager have been copied into folder \Zb/root/MoManager-${ORIGLANG12}-${APKGNAME}\ZB, and a tarball has been created, \Zb/root/MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz\ZB. Note, it contains \Zbwrite.log\ZB which records the details of each translation file.

The tarball can be sent to whoever is the author/maintainer of the \Zb${APKGNAME}\ZB package, however, we recommend that they be sent to the maintainer of the \Zb${ORIGLANG1} langpack\ZB PET package. At the time of writing this, these are some maintainers:
\Zbda\ZB maans
\Zbde\ZB L18L
\Zbel\ZB kounelii
\Zbes\ZB vicmz
\Zbfr\ZB esmourguit
\Zbit\ZB vicmz (temporary)
\Zbnl\ZB Bert
\Zbpl\ZB robwoj44
\Zbpt\ZB vicmz
\Zbru\ZB rodin.s
...these people can be contacted via the Puppy Linux Forum.

If there is no maintainer for a langpack for \Zb${ORIGLANG1}\ZB, then the invitation is extended to volunteer. You will notice the \ZbPET\ZB button on the main window -- a very easy way to create a PET package of all of the translations. Maintainers may also throw in any other relevant translations that they can find, even dictionary files, but not any binary executables as the PET has to be architecture-independent. When you have it working nicely, send it to me \ZbBarryK\ZB via the Puppy Forum."
 pupdialog --background green --colors --backtitle "MoManager: edit completed" --msgbox "${TARBALLMSG}" 0 0
}

#note: edit_mo and create_mo have much common code, *to do* eliminate duplication.
case $EXIT in
 edit_mo)
  #ex: YESMO_COMBO='/usr/sbin/mousecheck (de mousecheck.mo)'
  ASCRIPT="`echo -n "$YESMO_COMBO" | cut -f 1 -d '(' | rev | cut -f 2-9 -d ' ' | rev`"
  ANAME="`basename "$ASCRIPT"`"
  ATRANSLANG="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`" #ex: de
  AMO="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: mousecheck.mo
  APKGNAME="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 3 -d ' '`" #ex: bluefish  ex: WOOF
  AMOSPEC="/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  ATEXTDOMAIN="`basename $AMO .mo`"
  cp -f "$AMOSPEC" /tmp/momanager/${ATEXTDOMAIN}.moOLD
  msgunfmt "$AMOSPEC" > /tmp/momanager/${ATEXTDOMAIN}1.po
  cd /tmp/momanager
  case $ATEXTDOMAIN in
   alsaconf)
    #rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
    cp -f /usr/share/doc/nls/alsaconf/alsaconf.pot ./
   ;;
   *)
    #120731 why not generalize the above. any script(s) can have a pre-existing .pot file and it will be used...
    if [ -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ];then
     cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ./
    else
#     ALREADYSH="$(echo -n "$ANAME" | grep '\.sh$')" #120731
#     if [ "$ALREADYSH" = "" ];then
#      cp -f "$ASCRIPT" ${ANAME}.sh #hack
#      xANAME="${ANAME}.sh"
#     else
#      cp -f "$ASCRIPT" ${ANAME}
#      xANAME="$ANAME"
#     fi
     #120731 multiple scripts may have the same TEXTDOMAIN...
     tdPTN="^export TEXTDOMAIN=${ATEXTDOMAIN}"
     #EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "${tdPTN}" INPUTFILE | sed -e 's%SPACECHAR% %g' | grep -v -x "${ASCRIPT}")"
     #no, i will drop the $ANAME from above, and put them all in consistent order...
     EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "${tdPTN}" INPUTFILE | sed -e 's%SPACECHAR% %g')"
     if [ "$EXTRASCRIPTS" ];then
      echo -n "" > ./xEXTRASCRIPTS
      echo "$EXTRASCRIPTS" |
      while read ONEEXTRA
      do
       [ "$ONEEXTRA" = "" ] && continue
       [ ! -f "$ONEEXTRA" ] && continue #precaution.
       ONEBASE="$(basename "${ONEEXTRA}" .sh)"
       cp -f "$ONEEXTRA" ./${ONEBASE}.sh
       echo "${ONEBASE}.sh" >> ./xEXTRASCRIPTS
      done
      #LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap ${xANAME} `cat ./xEXTRASCRIPTS`
      LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap `cat ./xEXTRASCRIPTS`
#     else  #previous code...
#      LANG=${ORIGLANG} rxvt -e xgettext --no-wrap -o ${ATEXTDOMAIN}.pot ${xANAME}
     fi
    fi
   ;;
  esac
  #this syncs textdomain1.po and textdomain.pot, merges to textdomain.po ...
  rm -f ${ATEXTDOMAIN}.po 2>/dev/null
  #130526 L18L: intltool-update fails with ROX-Filer and xdialog, but msgmerge works...
  #LANG=${ORIGLANG} rxvt -e intltool-update --dist --gettext-package=${ATEXTDOMAIN} --output-file=${ATEXTDOMAIN}.po ${ATEXTDOMAIN}1
  LANG=${ORIGLANG} rxvt -e msgmerge ${ATEXTDOMAIN}1.po ${ATEXTDOMAIN}.pot --output-file=${ATEXTDOMAIN}.po ; #130526 L18L
  BINMSG="The .mo file has been converted to an editable .po file. Edit, then Save, then Quit text editor..."
  ROPID=0 ; POPCOL='yellow'
  #120308 intltool-update is broken with some pot files. need a fallback method...
  if [ ! -s ${ATEXTDOMAIN}.po ];then
   LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot #create po file without any translations.
   LANG=${ORIGLANG} defaulttextviewer /tmp/momanager/${ATEXTDOMAIN}1.po & #warning, this must be different from defaulttexteditor!
   ROPID=$!
   #BINMSG="BAD NEWS: the 'intltool-update' utility was unable to merge your existing translations with the pot file. Therefore, the translations are open in a separate file '${ATEXTDOMAIN}1.po' and you must paste them into '${ATEXTDOMAIN}.po' -- edit the latter only! Edit '${ATEXTDOMAIN}.po', save, then quit..."
   BINMSG="BAD NEWS: the 'msgmerge' utility was unable to merge your existing translations with the pot file. Therefore, the translations are open in a separate file '${ATEXTDOMAIN}1.po' and you must paste them into '${ATEXTDOMAIN}.po' -- edit the latter only! Edit '${ATEXTDOMAIN}.po', save, then quit..."
   POPCOL='LightPink'
  fi
  poptop_func "$BINMSG" $POPCOL
  
  #130502 L18L/BK: stay in a loop if there is an error converting .po to .mo...
  ABORTFLG=0
  cp -f /tmp/momanager/${ATEXTDOMAIN}.po /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1
  while true ; do
   if [ "$POEDITOR" ];then
    LANG=${ORIGLANG} ${POEDITOR} /tmp/momanager/${ATEXTDOMAIN}.po
   else
    killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
    sleep 0.5
    LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po
   fi
   if diff -q /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po  >/dev/null 2>&1; then #130503 130506
    ABORTFLG=8
    break
   fi
   LANG=${ORIGLANG} msgfmt --output-file=- /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>/tmp/momanager/po-2-mo.err
   [ ! -s /tmp/momanager/po-2-mo.err ] && break
   pupdialog --background '#FF8080' --backtitle "MoManager: po to mo fail" --extra-button --yes-label "Fix" --no-label "Abort" --extra-label "Revert" --yesno "There are errors in the .po file:

`cat /tmp/momanager/po-2-mo.err`

NOTE: The above error message is logged to /tmp/momanager/po-2-mo.err

Click the 'Fix' button to edit the .po file again...
Click 'Revert' to go back to original .po file, and try again...
Click 'Abort' to give up..." 0 0
   case $? in
    0)  continue  ;; #Fix
    3)  cp -f /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po ; continue ;; #Revert
    *)  ABORTFLG=9 ; break ;; #1=Abort
   esac
  done
  
  [ $ROPID -ne 0 ] && kill $ROPID
  if [ $ABORTFLG -eq 0 ];then #130502
   LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=/tmp/momanager/${ATEXTDOMAIN}.mo /tmp/momanager/${ATEXTDOMAIN}.po
   pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB. Note, as a precaution, the old mo file is at /tmp/momanager/${ATEXTDOMAIN}.moOLD." 0 0
   ABORTFLG=$?
  fi
  if [ $ABORTFLG -eq 0 ];then #130502
   cp -f /tmp/momanager/${ATEXTDOMAIN}.mo "${AMOSPEC}"
   #output as a tarball that user can email to pkg author...
   mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES
   cp -f /tmp/momanager/${ATEXTDOMAIN}.mo /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/
   ASTAT="`stat --format=%y "$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
   [ -f ${PATHPREFIX}${ASCRIPT} ] && ASTAT="`stat --format=%y "${PATHPREFIX}$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
   echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_SCRIPT=${ASTAT} SCRIPT='${ASCRIPT}' MO_FILE='${AMOSPEC}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
   cd /root
   mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
   dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
   tarball_func
  else
   pupdialog --background pink --backtitle "MoManager: mo edit aborted" --msgbox "You have declined to update the mo file. Ok, the previous one has been retained." 0 0
  fi
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 create_mo)
  #ex: NOMO_COMBO='/usr/sbin/mousecheck (mousecheck)'
  ASCRIPT="`echo -n "$NOMO_COMBO" | cut -f 1 -d '(' | rev | cut -f 2 -d ' ' | rev`"
  ATEXTDOMAIN="`echo -n "$NOMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`"
  APKGNAME="`echo -n "$NOMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: bluefish  ex: WOOFBUILTIN
  FIELD2ND="`echo -n "$ORIGLANG12" | cut -f 2 -d '_'`"
  pupdialog --colors --background yellow --backtitle "MoManager: mo language" --yes-label "${ORIGLANG1}" --no-label "${ORIGLANG12}" --yesno "Please click the \Zb${ORIGLANG1}\ZB button to create a translation file for that language. However, the \Zb${FIELD2ND}\ZB designates a particular country in which the language is used, and if you need such a specific translation then click the \Zb${ORIGLANG12}\ZB button. It is highly recommended that you click the \Zb${ORIGLANG1}\ZB button, unless you absolutely must have a country-specific translation..." 0 0
  if [ $? -eq 0 ];then
   ATRANSLANG="$ORIGLANG1"
  else
   ATRANSLANG="$ORIGLANG12"
  fi
#  ATEXTDOMAIN="`basename "$NOMO_COMBO"`"
#  if [ "`which $ATEXTDOMAIN`" = "" ];then #if not in path, then insert a prefix...
#   adirspec="`dirname "$NOMO_COMBO"`"
#   aprefix="`basename "$adirspec" | sed -e 's%[^a-zA-Z0-9]%%g'`"
#   ATEXTDOMAIN="${aprefix}___${ATEXTDOMAIN}"
#  fi
  ANAME="`basename "$ASCRIPT"`"
  AMO="${ATEXTDOMAIN}.mo"
  AMOSPEC="/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  mkdir -p /usr/share/locale/${ATRANSLANG}/LC_MESSAGES
  cd /tmp/momanager
#  ALREADYSH="$(echo -n "$ANAME" | grep '\.sh$')" #120731
#  if [ "$ALREADYSH" = "" ];then
#   cp -f "$ASCRIPT" ${ANAME}.sh #hack, i think the .sh helps xgettext.
#   xANAME="${ANAME}.sh"
#  else
#   cp -f "$ASCRIPT" ${ANAME}
#   xANAME="$ANAME"
#  fi
  case $ATEXTDOMAIN in
   alsaconf)
    #rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
    cp -f /usr/share/doc/nls/alsaconf/alsaconf.pot ./
   ;;
   *)
    #120731 why not generalize the above. any script(s) can have a pre-existing .pot file and it will be used...
    if [ -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ];then
     cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ./
    else
     #120731 multiple scripts may have the same TEXTDOMAIN...
     tdPTN="^export TEXTDOMAIN=${ATEXTDOMAIN}"
     #EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "${tdPTN}" INPUTFILE | sed -e 's%SPACECHAR% %g' | grep -v -x "${ASCRIPT}")"
     #no, i will drop the $ANAME from above, and put them all in consistent order...
     EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "${tdPTN}" INPUTFILE | sed -e 's%SPACECHAR% %g')"
     if [ "$EXTRASCRIPTS" ];then
      echo -n "" > ./xEXTRASCRIPTS
      echo "$EXTRASCRIPTS" |
      while read ONEEXTRA
      do
       [ "$ONEEXTRA" = "" ] && continue
       [ ! -f "$ONEEXTRA" ] && continue #precaution.
       ONEBASE="$(basename "${ONEEXTRA}" .sh)"
       cp -f "$ONEEXTRA" ./${ONEBASE}.sh
       echo "${ONEBASE}.sh" >> ./xEXTRASCRIPTS
      done
      #LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap ${xANAME} `cat ./xEXTRASCRIPTS`
      LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap `cat ./xEXTRASCRIPTS`
#     else  #previous code...
#      LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap ${xANAME}
      aPTN="s%Project-Id-Version: PACKAGE VERSION%Project-Id-Version: ${ANAME} VERSION%"
      bPTN="s%Content-Type: text/plain; charset=CHARSET%Content-Type: text/plain; charset=UTF-8%"
      cPTN="s% PACKAGE package% ${ANAME} package%"
      #dPTN="s%Content-Type: text/plain; charset=ASCII%Content-Type: text/plain; charset=UTF-8%"
      sed -i -e "$aPTN" -e "$bPTN" -e "$cPTN" ${ATEXTDOMAIN}.pot
     fi
    fi
   ;;
  esac
  LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot
  sync
  poptop_func "The translation file is now open in a text editor. Edit, then Save, then Quit text editor..."

  #130502 L18L/BK: stay in a loop if there is an error converting .po to .mo...
  ABORTFLG=0
  cp -f /tmp/momanager/${ATEXTDOMAIN}.po /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1
  while true ; do
   if [ "$POEDITOR" ];then
    LANG=${ORIGLANG} ${POEDITOR} /tmp/momanager/${ATEXTDOMAIN}.po
   else
    killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
    sleep 0.5
    LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po
   fi
   if diff -q /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po  >/dev/null 2>&1; then #130503 130506
    ABORTFLG=8
    break
   fi
   LANG=${ORIGLANG} msgfmt --output-file=- /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>/tmp/momanager/po-2-mo.err
   [ ! -s /tmp/momanager/po-2-mo.err ] && break
   pupdialog --background '#FF8080' --backtitle "MoManager: po to mo fail" --extra-button --yes-label "Fix" --no-label "Abort" --extra-label "Revert" --yesno "There are errors in the .po file:

`cat /tmp/momanager/po-2-mo.err`

NOTE: The above error message is logged to /tmp/momanager/po-2-mo.err

Click the 'Fix' button to edit the .po file again...
Click 'Revert' to go back to original .po file, and try again...
Click 'Abort' to give up..." 0 0
   case $? in
    0)  continue  ;; #Fix
    3)  cp -f /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po ; continue ;; #Revert
    *)  ABORTFLG=9 ; break ;; #1=Abort
   esac
  done

  if [ $ABORTFLG -eq 0 ];then #130502
   LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=/tmp/momanager/${ATEXTDOMAIN}.mo /tmp/momanager/${ATEXTDOMAIN}.po
   pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo (the former being the editable translation file and the latter being the compiled translation file). If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB." 0 0
   ABORTFLG=$?
  fi
  case $ABORTFLG in #130502
   0)
    cp -f /tmp/momanager/${ATEXTDOMAIN}.mo "${AMOSPEC}"
    #output as a tarball that user can email to pkg author...
    mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES
    cp -f /tmp/momanager/${ATEXTDOMAIN}.mo /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/
    ASTAT="`stat --format=%y "$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
    [ -f ${PATHPREFIX}${ASCRIPT} ] && ASTAT="`stat --format=%y "${PATHPREFIX}$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
    echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_SCRIPT=${ASTAT} SCRIPT='${ASCRIPT}' MO_FILE='${AMOSPEC}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
    cd /root
    mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
    dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
    tarball_func
   ;;
   8) #130503
    pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You did not change ${ATEXTDOMAIN}.po, so operation aborted." 0 0
   ;;
   9)
    pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You failed to convert ${ATEXTDOMAIN}.po to an .mo file, so operation aborted." 0 0
   ;;
   *)
    pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You have declined to use the mo file. Ok, it has been left at /tmp/momanager/${ATEXTDOMAIN}.mo and will not be used." 0 0
   ;;
  esac
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 edit_desk|create_desk)
  if [ "$EXIT" = "edit_desk" ];then
   DESKFILE="`echo -n "$YESDESK_COMBO" | cut -f 1 -d ' '`"
   APKGNAME="`echo -n "$YESDESK_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
   cp -f -a /usr/share/applications/$DESKFILE /tmp/momanager/
  else
   DESKFILE="`echo -n "$NODESK_COMBO" | cut -f 1 -d ' '`"
   APKGNAME="`echo -n "$NODESK_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
   cp -f -a /usr/share/applications/$DESKFILE /tmp/momanager/
   sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" /usr/share/applications/$DESKFILE
  fi
  sync
  killall geany 2>/dev/null
  poptop_func "The menu file is now open in a text editor. Edit, then Save, then Quit text editor..."
  ASTAT="`stat --format=%y "/usr/share/applications/$DESKFILE" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  [ -f ${PATHPREFIX}/usr/share/applications/$DESKFILE ] && ASTAT="`stat --format=%y "${PATHPREFIX}/usr/share/applications/$DESKFILE" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  xASTAT1="`stat --format=%Y "/usr/share/applications/$DESKFILE"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor /usr/share/applications/$DESKFILE
  xASTAT2="`stat --format=%Y "/usr/share/applications/$DESKFILE"`" #seconds since epoch.
  if [ "`grep 'PLEASE INSERT YOUR TRANSLATION HERE' /usr/share/applications/$DESKFILE`" != "" ];then
   mv -f /tmp/momanager/$DESKFILE /usr/share/applications/
   xASTAT2="$xASTAT1"
  fi
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  yaf-splash -bg '#80FF80' -timeout 3 -text "The menu is being updated..." &
  LANG=$ORIGLANG /usr/sbin/fixmenus
  if [ "`pidof jwm`" != "" ];then
   JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
   if vercmp $JWMVER lt 574;then
    LANG=${ORIGLANG} jwm -restart
   else
    LANG=${ORIGLANG} jwm -reload
   fi
  fi
  cp -f /usr/share/applications/$DESKFILE /root/
  #add translation to tarball that user can email to pkg author...
  cd /root
  mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications
  cp -f /usr/share/applications/$DESKFILE /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications/
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} DESKTOP_FILE='/usr/share/applications/${DESKFILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  cd /root
  mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 edit_top|create_top) #menu categories.
  APKGNAME='WOOF'
  if [ "$EXIT" = "edit_top" ];then
   TOPFILE="$YESTOP_COMBO"
   cp -f -a /usr/share/desktop-directories/$TOPFILE /tmp/momanager/
  else
   TOPFILE="$NOTOP_COMBO"
   cp -f -a /usr/share/desktop-directories/$TOPFILE /tmp/momanager/
   sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" /usr/share/desktop-directories/$TOPFILE
  fi
  sync
  killall geany 2>/dev/null
  poptop_func "The menu-category file is now open in a text editor. Edit, then Save, then Quit text editor..."
  ASTAT="`stat --format=%y "/usr/share/desktop-directories/$TOPFILE" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  [ -f ${PATHPREFIX}/usr/share/desktop-directories/$TOPFILE ] && ASTAT="`stat --format=%y "${PATHPREFIX}/usr/share/desktop-directories/$TOPFILE" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  xASTAT1="`stat --format=%Y "/usr/share/desktop-directories/$TOPFILE"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor /usr/share/desktop-directories/$TOPFILE
  xASTAT2="`stat --format=%Y "/usr/share/desktop-directories/$TOPFILE"`" #seconds since epoch.

  if [ "`grep 'PLEASE INSERT YOUR TRANSLATION HERE' /usr/share/desktop-directories/$TOPFILE`" != "" ];then
   mv -f /tmp/momanager/$TOPFILE /usr/share/desktop-directories/
   xASTAT2="$xASTAT1"
  fi
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  yaf-splash -bg '#80FF80' -timeout 3 -text "The menu is being updated..." &
  LANG=$ORIGLANG /usr/sbin/fixmenus
  if [ "`pidof jwm`" != "" ];then
   JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
   if vercmp $JWMVER lt 574;then
    LANG=${ORIGLANG} jwm -restart
   else
    LANG=${ORIGLANG} jwm -reload
   fi
  fi
  cp -f /usr/share/desktop-directories/$TOPFILE /root/
  #add translation to tarball that user can email to pkg author...
  cd /root
  mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications
  cp -f /usr/share/desktop-directories/$TOPFILE /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications/
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} CATEGORY_FILE='/usr/share/desktop-directories/${TOPFILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  cd /root
  mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 create_sss) #BK's Simple String Substitution method.
  APKGNAME="WOOF"
  SSSFILE="$NOSSS_COMBO" #ex: menu_strings (located at /usr/share/sss/menu_strings/)
  cp -f /usr/share/sss/$SSSFILE/$SSSFILE /tmp/momanager/$SSSFILE.$ORIGLANG1
  sync
  
  #120224 special handling req'd for doc_strings...
  if [ "$SSSFILE" = "doc_strings" ];then
   cp -f /usr/share/sss/$SSSFILE/$SSSFILE /usr/share/sss/$SSSFILE/$SSSFILE.$ORIGLANG1
   #ask what files want to edit (instead of just cycling through all of them)...
   CNT=0 ; CHKBOX_XML=""
   for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
   do
    [ "$ASECTIONID" = "general" ] && continue
    MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
    TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
    [ ! -f "$TARGETFILE" ] && continue #precaution.
    CNT=$(($CNT + 1))
    CHKBOX_XML="${CHKBOX_XML}
<checkbox><variable>CHKBOX_${CNT}_</variable><default>true</default><label>${TARGETFILE}</label></checkbox>"
   done
   export MMx_DLG="<window title=\"MoManager: Documentation files\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
   <vbox>
    <text><label>Please select the documentation files that you want to edit:</label></text>
    ${CHKBOX_XML}
    <hbox><button ok></button><button cancel></button></hbox>
   </vbox>
   </window>"
   MMxRET="`$GTKDIALOGEXE --program=MMx_DLG`"
   #now edit the doc files...
   for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
   do
    [ "$ASECTIONID" = "general" ] && continue
    sPTN="/^\[${ASECTIONID}\]/,/^$/p" #this is a multi-line block find expression.
    CODEBLOCK="`sed -n "$sPTN" /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | sed -e '/^#/d' -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
    [ ! "$CODEBLOCK" ] && continue #precaution.
    #allow any character to be the 'marker' for / in the section-id...
    MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
    TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
    [ ! -f "$TARGETFILE" ] && continue #precaution.
    WHICHCHKBOX="`echo "$CHKBOX_XML" | grep "$TARGETFILE" | head -n 1 | grep -o 'CHKBOX_[0-9]*_'`"
    [ "`echo "$MMxRET" | grep "$WHICHCHKBOX" | grep 'true'`" = "" ] && continue #not selected
    SSS_POST_EXEC=""
    eval "$CODEBLOCK" #has variables SSS_HANDLER_EDITOR, SSS_TRANSLATION_RULE, SSS_HANDLER_VIEWER [, SSS_POST_EXEC]
    SSS_TRANSLATION_FILE="`echo -n "$SSS_TRANSLATION_RULE" | sed -e "s%SSSLANG1MARKER%${ORIGLANG1}%"`"
    if [ "$TARGETFILE" = "$SSS_TRANSLATION_FILE" ];then
     #the translation is completely replacing the english file, so make a backup of the en file...
     FILETYPE="`echo -n "$TARGETFILE" | rev | cut -f 1 -d '.' | rev`" #ex: htm
     ftPTN="s%\.${FILETYPE}$%-en.${FILETYPE}%"
     ENFILE="`echo -n "$TARGETFILE" | sed -e "$ftPTN"`"
     if [ ! -f "$ENFILE" ];then
      if [ -f ${PATHPREFIX}"${TARGETFILE}" ];then
       cp -f ${PATHPREFIX}"${TARGETFILE}" "$ENFILE" #get it from sfs layer, to ensure it is en.
      else
       cp -f "${TARGETFILE}" "$ENFILE"
      fi
     fi
     TARGETFILE="$ENFILE"
    fi
    killall seamonkey 2>/dev/null
    killall seamonkey-bin 2>/dev/null
    killall geany 2>/dev/null
    [ ! -f "$SSS_TRANSLATION_FILE" ] && cp -a -f $TARGETFILE $SSS_TRANSLATION_FILE
    poptop_func "This is the original English file. Use this for reference only, do not edit. PLEASE WAIT..." orange 9
    LANG=${ORIGLANG} ${SSS_HANDLER_VIEWER} "$TARGETFILE" &
    dPID=$!
    sleep 10
    poptop_func "You must translate all of the text in this file to '${ORIGLANG1}' language. Edit, then Save, then Quit. Note, if you do not want to change anything, just Quit the editor..." yellow 11
    xASTAT1="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
    LANG=${ORIGLANG} ${SSS_HANDLER_EDITOR} ${SSS_TRANSLATION_FILE}
    xASTAT2="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
    kill $dPID
    [ "$xASTAT1" = "$xASTAT2" ] && continue
    DIRTRANSLATIONFILE="`dirname "${SSS_TRANSLATION_FILE}"`"
    mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}
    cp -a -f "${SSS_TRANSLATION_FILE}" /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}/
    echo "MACTION=${EXIT} TODAY_DATE=${ADATE} TRANS_FILE='${SSS_TRANSLATION_FILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
    [ "$SSS_POST_EXEC" ] && ${SSS_POST_EXEC}
    pupdialog --background green --colors --backtitle "MoManager: SSS edit completed" --msgbox "You have translated file \Zb${SSS_TRANSLATION_FILE}\ZB. Click OK button to continue..." 0 0
   done
   mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}
   echo "MACTION=${EXIT} TODAY_DATE=${ADATE} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
   mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   cp -f /usr/share/sss/${SSSFILE}/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  
  killall geany 2>/dev/null
  poptop_func "The SSS file is now open in a text editor. You must only edit between the last two % characters. Edit, then Save, then Quit text editor..."
  ASTAT="`stat --format=%y "/usr/share/sss/$SSSFILE/$SSSFILE" | cut -f 1 -d ' ' | tr -d '-'`" #so can check against file version in latest Woof.
  [ -f ${PATHPREFIX}/usr/share/sss/$SSSFILE/$SSSFILE ] && ASTAT="`stat --format=%y "${PATHPREFIX}/usr/share/sss/$SSSFILE/$SSSFILE" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  xASTAT1="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/$SSSFILE.$ORIGLANG1
  xASTAT2="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  [ "$SSSFILE" = "desk_strings" ] && fixdesk en #120212 translate all target files back to english. (using old $SSSFILE)
  [ "$SSSFILE" = "script_strings" ] && fixscripts en #120212 translate all target files back to english. (using old $SSSFILE)
  cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /usr/share/sss/$SSSFILE/
  [ "$SSSFILE" = "desk_strings" ] && fixdesk $ORIGLANG1 #120212 translate all target files back to current language. (using new SSSFILE)
  [ "$SSSFILE" = "script_strings" ] && fixscripts $ORIGLANG1 #120212 translate all target files back to current language. (using new SSSFILE)
  yaf-splash -bg '#80FF80' -timeout 3 -text "The desktop and menus are being updated..." &
  LANG=$ORIGLANG /usr/sbin/fixmenus
  if [ "`pidof jwm`" != "" ];then
   JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
   if vercmp $JWMVER lt 574;then
    LANG=${ORIGLANG} jwm -restart
   else
    LANG=${ORIGLANG} jwm -reload
   fi
  fi
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  cd /root
  mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 edit_sss)
  APKGNAME="WOOF"
  SSSFILE="$YESSSS_COMBO" #ex: menu_strings.de (located at /usr/share/sss/menu_strings/)
  SSSFILE="`echo -n "$SSSFILE" | rev | cut -f 2-9 -d '.' | rev`" #dump the extension, ex: menu_strings.de -> menu_strings
  #cp -f /usr/share/sss/$SSSFILE/$SSSFILE.$ORIGLANG1 /tmp/momanager/$SSSFILE.$ORIGLANG1
  
  #120224 special handling req'd for doc_strings...
  if [ "$SSSFILE" = "doc_strings" ];then
   #ask what files want to edit (instead of just cycling through all of them)...
   CNT=0 ; CHKBOX_XML=""
   for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
   do
    [ "$ASECTIONID" = "general" ] && continue
    MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
    TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
    [ ! -f "$TARGETFILE" ] && continue #precaution.
    CNT=$(($CNT + 1))
    CHKBOX_XML="${CHKBOX_XML}
<checkbox><variable>CHKBOX_${CNT}_</variable><default>true</default><label>${TARGETFILE}</label></checkbox>"
   done
   export MMx_DLG="<window title=\"MoManager: Documentation files\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
   <vbox>
    <text><label>Please select the documentation files that you want to edit:</label></text>
    ${CHKBOX_XML}
    <hbox><button ok></button><button cancel></button></hbox>
   </vbox>
   </window>"
   MMxRET="`$GTKDIALOGEXE --program=MMx_DLG`"
   #now edit the doc files...
   for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
   do
    [ "$ASECTIONID" = "general" ] && continue
    sPTN="/^\[${ASECTIONID}\]/,/^$/p" #this is a multi-line block find expression.
    CODEBLOCK="`sed -n "$sPTN" /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | sed -e '/^#/d' -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
    [ ! "$CODEBLOCK" ] && continue #precaution.
    #allow any character to be the 'marker' for / in the section-id...
    MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
    TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
    [ ! -f "$TARGETFILE" ] && continue #precaution.
    WHICHCHKBOX="`echo "$CHKBOX_XML" | grep "$TARGETFILE" | head -n 1 | grep -o 'CHKBOX_[0-9]*_'`"
    [ "`echo "$MMxRET" | grep "$WHICHCHKBOX" | grep 'true'`" = "" ] && continue #not selected
    SSS_POST_EXEC=""
    eval "$CODEBLOCK" #has variables SSS_HANDLER_EDITOR, SSS_TRANSLATION_RULE, SSS_HANDLER_VIEWER [, SSS_POST_EXEC]
    SSS_TRANSLATION_FILE="`echo -n "$SSS_TRANSLATION_RULE" | sed -e "s%SSSLANG1MARKER%${ORIGLANG1}%"`"
    if [ "$TARGETFILE" = "$SSS_TRANSLATION_FILE" ];then
     #the translation is completely replacing the english file, so make a backup of the en file...
     FILETYPE="`echo -n "$TARGETFILE" | rev | cut -f 1 -d '.' | rev`" #ex: htm
     ftPTN="s%\.${FILETYPE}$%-en.${FILETYPE}%"
     ENFILE="`echo -n "$TARGETFILE" | sed -e "$ftPTN"`"
     if [ ! -f "$ENFILE" ];then
      if [ -f ${PATHPREFIX}"${TARGETFILE}" ];then
       cp -f ${PATHPREFIX}"${TARGETFILE}" "$ENFILE" #get it from sfs layer, to ensure it is en.
      else
       cp -f "${TARGETFILE}" "$ENFILE"
      fi
     fi
     TARGETFILE="$ENFILE"
    fi
    killall seamonkey 2>/dev/null
    killall seamonkey-bin 2>/dev/null
    killall geany 2>/dev/null
    [ ! -f "$SSS_TRANSLATION_FILE" ] && cp -a -f $TARGETFILE $SSS_TRANSLATION_FILE
    poptop_func "This is the original English file. Use this for reference only, do not edit. PLEASE WAIT..." orange
    LANG=${ORIGLANG} ${SSS_HANDLER_VIEWER} "$TARGETFILE" &
    dPID=$!
    sleep 10
    poptop_func "You must translate all of the text in this file to '${ORIGLANG1}' language. Edit, then Save, then Quit. Note, if you do not want to change anything, just Quit the editor..." yellow 11
    xASTAT1="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
    LANG=${ORIGLANG} ${SSS_HANDLER_EDITOR} ${SSS_TRANSLATION_FILE}
    xASTAT2="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
    kill $dPID
    [ "$xASTAT1" = "$xASTAT2" ] && continue
    DIRTRANSLATIONFILE="`dirname "${SSS_TRANSLATION_FILE}"`"
    mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}
    cp -a -f "${SSS_TRANSLATION_FILE}" /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}/
    echo "MACTION=${EXIT} TODAY_DATE=${ADATE} TRANS_FILE='${SSS_TRANSLATION_FILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
    [ "$SSS_POST_EXEC" ] && ${SSS_POST_EXEC}
    pupdialog --background green --colors --backtitle "MoManager: SSS edit completed" --msgbox "You have translated file \Zb${SSS_TRANSLATION_FILE}\ZB. Click OK button to continue..." 0 0
   done
   mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}
   echo "MACTION=${EXIT} TODAY_DATE=${ADATE} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
   mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   cp -f /usr/share/sss/${SSSFILE}/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  
  #sync translated sss-file with original (master) sss-file (/usr/share/sss/$SSSFILE/$SSSFILE)...
  #ex: 'menu_strings' is the master (no translations in it), 'menu_strings.de' has German translations.
  #(Woof developers only have to edit the master, and the translation sss-files will sync to it).
  #to do this properly have to write code that analyses the sss-files by section, that is, the files
  #have sections, separated by blank lines and headed by an identifier, ex "[_woof_.jwmrc]"
  #note: /usr/sbin/fixmenus has example sed to extract an sss section.
  echo -n "" > /tmp/momanager/$SSSFILE.$ORIGLANG1
  for ASECTIONID in `grep '^\[' /usr/share/sss/${SSSFILE}/${SSSFILE} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _woof_.jwmrc
  do
   sPTN="/^\[${ASECTIONID}\]/,/^$/p" #this is a multi-line block find expression.
   ENCODEBLOCK="`sed -n "$sPTN" /usr/share/sss/${SSSFILE}/${SSSFILE} | sed -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
   case $ASECTIONID in
    general)
     #this section is just comments, pass it straight thru...
     echo '[general]' >> /tmp/momanager/$SSSFILE.$ORIGLANG1
     echo "$ENCODEBLOCK" >> /tmp/momanager/$SSSFILE.$ORIGLANG1
     echo  >> /tmp/momanager/$SSSFILE.$ORIGLANG1
    ;;
    *)
     echo "[${ASECTIONID}]" >> /tmp/momanager/$SSSFILE.$ORIGLANG1
     #find same section in the translated sss-file...
     TRCODEBLOCK="`sed -n "$sPTN" /usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1} | sed -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
     echo "$TRCODEBLOCK" | #sed -e 's%\\%\\\\%g' | #121124 pass \ thru read
     while read -r ATRLINE #121124 -r then backslash is not an escape.
     do
      case $ATRLINE in
       CODESTRING*)
        eval "$ATRLINE"
        OKLINE="`echo "$ENCODEBLOCK" | grep "$CODESTRING" | grep "$ENGLISH"`"
        [ "$OKLINE" ] && echo "$ATRLINE" >> /tmp/momanager/$SSSFILE.$ORIGLANG1 #match, so keep it.
       ;;
       *)
        echo "$ATRLINE" >> /tmp/momanager/$SSSFILE.$ORIGLANG1 #probably a comment line.
       ;;
      esac
     done
     #now do it the other way around...
     echo "$ENCODEBLOCK" | #sed -e 's%\\%\\\\%g' | #121124 pass \ thru read
     while read -r AENLINE #121124 -r then backslash is not an escape.
     do
      case $AENLINE in
       CODESTRING*)
        eval "$AENLINE"
        OKLINE="`echo "$TRCODEBLOCK" | grep "$CODESTRING" | grep "$ENGLISH"`"
        [ ! "$OKLINE" ] && echo "$AENLINE" >> /tmp/momanager/$SSSFILE.$ORIGLANG1 #new line not in translated sss-file, so write it (not yet translated).
       ;;
      esac
     done
     echo  >> /tmp/momanager/$SSSFILE.$ORIGLANG1
    ;;
   esac
  done
  echo  >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  
  sync
  killall geany 2>/dev/null
  poptop_func "The SSS file is now open in a text editor. You must only edit between the last two % characters. Edit, then Save, then Quit text editor..."
  ASTAT="`stat --format=%y "/usr/share/sss/$SSSFILE/$SSSFILE.$ORIGLANG1" | cut -f 1 -d ' ' | tr -d '-'`" #so can check against file version in latest Woof.
  [ -f ${PATHPREFIX}/usr/share/sss/$SSSFILE/$SSSFILE.$ORIGLANG1 ] && ASTAT="`stat --format=%y "${PATHPREFIX}/usr/share/sss/$SSSFILE/$SSSFILE.$ORIGLANG1" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  xASTAT1="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/$SSSFILE.$ORIGLANG1
  xASTAT2="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  [ "$SSSFILE" = "desk_strings" ] && fixdesk en #120209 translate all target files back to english. (using old $SSSFILE)
  [ "$SSSFILE" = "script_strings" ] && fixscripts en #120209 translate all target files back to english. (using old $SSSFILE)
  cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /usr/share/sss/$SSSFILE/
  [ "$SSSFILE" = "desk_strings" ] && fixdesk $ORIGLANG1 #120209 translate all target files back to current language. (using new SSSFILE)
  [ "$SSSFILE" = "script_strings" ] && fixscripts $ORIGLANG1 #120209 translate all target files back to current language. (using new SSSFILE)
  yaf-splash -bg '#80FF80' -timeout 3 -text "The desktop and menus are being updated..." &
  LANG=$ORIGLANG /usr/sbin/fixmenus
  if [ "`pidof jwm`" != "" ];then
   JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
   if vercmp $JWMVER lt 574;then
    LANG=${ORIGLANG} jwm -restart
   else
    LANG=${ORIGLANG} jwm -reload
   fi
  fi
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  cd /root
  mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 edit_xml|create_xml) #XML data files.
  if [ "$EXIT" = "edit_xml" ];then
   XMLFILE="`echo -n "$YESXML_COMBO" | cut -f 1 -d ' '`"
   APKGNAME="`echo -n "$YESXML_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
  else
   XMLFILE="`echo -n "$NOXML_COMBO" | cut -f 1 -d ' '`"
   APKGNAME="`echo -n "$NOXML_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
  fi
  sync
  killall geany 2>/dev/null
  poptop_func "The XML file is now open in a text editor. Edit, then Save, then Quit text editor..."
  ASTAT="`stat --format=%y "$XMLFILE" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  [ -f "${PATHPREFIX}${XMLFILE}" ] && ASTAT="`stat --format=%y "${PATHPREFIX}${XMLFILE}" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  xASTAT1="`stat --format=%Y "${XMLFILE}"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor "${XMLFILE}"
  xASTAT2="`stat --format=%Y "${XMLFILE}"`" #seconds since epoch.
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  #add translation to tarball that user can email to pkg author...
  cd /root
  PATHXMLFILE="`dirname "$XMLFILE"`"
  BASEXMLFILE="`basename "$XMLFILE"`"
  mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}"${PATHXMLFILE}"
  cp -f "$XMLFILE" /root/MoManager-${ORIGLANG12}-${APKGNAME}"${PATHXMLFILE}"/
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} CATEGORY_FILE='${XMLFILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  cd /root
  mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 edit_bin|create_bin) #binary executables.
  if [ "$EXIT" = "edit_bin" ];then
   ABIN="`echo -n "$YESBIN_COMBO" | cut -f 1 -d '(' | rev | cut -f 2-9 -d ' ' | rev`"
   ANAME="`basename "$ABIN"`"
   ATRANSLANG="`echo -n "$YESBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`" #ex: de
   AMO="`echo -n "$YESBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: mousecheck.mo
   APKGNAME="`echo -n "$YESBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 3 -d ' '`" #ex: bluefish  ex: WOOF
   ATEXTDOMAIN="`basename $AMO .mo`"
  else
   ABIN="`echo -n "$NOBIN_COMBO" | cut -f 1 -d '(' | rev | cut -f 2 -d ' ' | rev`"
   ATEXTDOMAIN="`echo -n "$NOBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`"
   APKGNAME="`echo -n "$NOBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: bluefish  ex: WOOF
   FIELD2ND="`echo -n "$ORIGLANG12" | cut -f 2 -d '_'`"
   pupdialog --colors --background yellow --backtitle "MoManager: mo language" --yes-label "${ORIGLANG1}" --no-label "${ORIGLANG12}" --yesno "Please click the \Zb${ORIGLANG1}\ZB button to create a translation file for that language. However, the \Zb${FIELD2ND}\ZB designates a particular country in which the language is used, and if you need such a specific translation then click the \Zb${ORIGLANG12}\ZB button. It is highly recommended that you click the \Zb${ORIGLANG1}\ZB button, unless you absolutely must have a country-specific translation..." 0 0
   if [ $? -eq 0 ];then
    ATRANSLANG="$ORIGLANG1"
   else
    ATRANSLANG="$ORIGLANG12"
   fi
   ANAME="`basename "$ABIN"`"
   AMO="${ATEXTDOMAIN}.mo"
  fi
  PREFIXLOCALEDIR='/usr/share/locale' #120308
  #120308 there are exceptions to /usr/share/locale. unfortunately looks like i have to hard-code those...
  case $ATEXTDOMAIN in
   ROX-Filer) PREFIXLOCALEDIR='/usr/local/apps/ROX-Filer/Messages' ;;
  esac
  AMOSPEC="${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  mkdir -p "${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES" #120308
  cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot /tmp/momanager/
  cd /tmp/momanager
  ROPID=0 ; POPCOL='yellow'
  BINMSG="A po file is open for editing. Edit, then Save, then Quit text editor..."
  if [ -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po ];then #120309 use pre-existing po file.
   cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po ./${ATEXTDOMAIN}.po
   BINMSG="A po file is open for editing. NOTE: this file was obtained from /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po. Edit, then Save, then Quit text editor..."
   [ -f "$AMOSPEC" ] && cp -f "$AMOSPEC" /tmp/momanager/${ATEXTDOMAIN}.moOLD
  else
   if [ "$EXIT" = "edit_bin" ];then
    cp -f "$AMOSPEC" /tmp/momanager/${ATEXTDOMAIN}.moOLD
    msgunfmt "$AMOSPEC" > /tmp/momanager/${ATEXTDOMAIN}1.po
    #this syncs textdomain1.po and textdomain.pot, merges to textdomain.po ...
    rm -f ${ATEXTDOMAIN}.po 2>/dev/null
    #130526 L18L: intltool-update fails with ROX-Filer and xdialog, but msgmerge works...
    #LANG=${ORIGLANG} rxvt -e intltool-update --dist --gettext-package=${ATEXTDOMAIN} --output-file=${ATEXTDOMAIN}.po ${ATEXTDOMAIN}1
    LANG=${ORIGLANG} rxvt -e msgmerge ${ATEXTDOMAIN}1.po ${ATEXTDOMAIN}.pot --output-file=${ATEXTDOMAIN}.po ; #130526 L18L
    BINMSG="A mo file has been converted to an editable po file. Edit, then Save, then Quit text editor..."
    #120308 intltool-update is broken with ROX-Filer.pot. need a fallback method...
    if [ ! -s ${ATEXTDOMAIN}.po ];then
     LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot #create po file without any translations.
     LANG=${ORIGLANG} defaulttextviewer /tmp/momanager/${ATEXTDOMAIN}1.po & #warning, this must be different from defaulttexteditor!
     ROPID=$!
     #BINMSG="BAD NEWS: the 'intltool-update' utility was unable to merge your existing translations with the pot file. Therefore, the translations are open in a separate file '${ATEXTDOMAIN}1.po' and you must paste them into '${ATEXTDOMAIN}.po' -- edit the latter only! Edit '${ATEXTDOMAIN}.po', save, then quit..."
     BINMSG="BAD NEWS: the 'msgmerge' utility was unable to merge your existing translations with the pot file. Therefore, the translations are open in a separate file '${ATEXTDOMAIN}1.po' and you must paste them into '${ATEXTDOMAIN}.po' -- edit the latter only! Edit '${ATEXTDOMAIN}.po', save, then quit..."
     POPCOL='LightPink'
    fi
   else
    LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot
   fi
  fi
  sync
  poptop_func "$BINMSG" $POPCOL
  zASTAT1="`stat --format=%Y /tmp/momanager/${ATEXTDOMAIN}.po`" #120309 modify date, seconds.
  if [ "$POEDITOR" ];then
   ${POEDITOR} /tmp/momanager/${ATEXTDOMAIN}.po
  else
   killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
   sleep 0.5
   LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po
  fi
  [ $ROPID -ne 0 ] && kill $ROPID
  zASTAT2="`stat --format=%Y /tmp/momanager/${ATEXTDOMAIN}.po`" #120309 modify date.
  if [ "$zASTAT1" = "$zASTAT2" ];then #120309
   export LANG=$ORIGLANG
   exec momanager reenter
  fi
  LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=/tmp/momanager/${ATEXTDOMAIN}.mo /tmp/momanager/${ATEXTDOMAIN}.po
#  pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB. Note, as a precaution, the old mo file is at /tmp/momanager/${ATEXTDOMAIN}.moOLD." 0 0
  pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --extra-button --extra-label "OK, keep po" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB. Note, as a precaution, the old mo file is at /tmp/momanager/${ATEXTDOMAIN}.moOLD.

WARNING: If there is an existing mo file, MoManager uncompiles it and merges with the pot file, to create the editable po file. However, sometimes this process fails (ROX-Filer for example). In such a case, you can click the \ZbOK, keep po\ZB button, which will retain the po file at \Zb/usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po\ZB, for use next time that you want to edit it with MoManager. Note, if uncertain, do not click this button." 0 0 #120309
  RETVAL=$?
  if [ $RETVAL -eq 3 ];then #extra button
   cp -f /tmp/momanager/${ATEXTDOMAIN}.po /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po
   RETVAL=0
  fi
  if [ $RETVAL -eq 0 ];then
   cp -f /tmp/momanager/${ATEXTDOMAIN}.mo "${AMOSPEC}"
   #output as a tarball that user can email to pkg author...
   mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES
   cp -f /tmp/momanager/${ATEXTDOMAIN}.mo /root/MoManager-${ORIGLANG12}-${APKGNAME}${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES/
   ASTAT="`stat --format=%y "$ABIN" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
   [ -f ${PATHPREFIX}${ABIN} ] && ASTAT="`stat --format=%y "${PATHPREFIX}$ABIN" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
   echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_BINARY=${ASTAT} BINARY='${ABIN}' MO_FILE='${AMOSPEC}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
   cd /root
   mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
   dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
   tarball_func
  else
   pupdialog --background pink --backtitle "MoManager: mo edit aborted" --msgbox "You have declined to update the mo file." 0 0
  fi
  export LANG=$ORIGLANG
  exec momanager reenter
 ;;
 
 create_pet) #create a langpack PET
  mv -f /root/langpack_${GENLANG}-${ADATE}.pet /root/langpack_${GENLANG}-${ADATE}.petOLD 2>/dev/null
  [ -d /root/langpack_${GENLANG}-${ADATE} ] && rm -rf /root/langpack_${GENLANG}-${ADATE}
  mkdir /root/langpack_${GENLANG}-${ADATE}
  cp -a -f /usr/share/doc/langpack-template/* /root/langpack_${GENLANG}-${ADATE}/
  echo "langpack_${GENLANG}-${ADATE}|langpack_${GENLANG}|${ADATE}||Setup|1104K||langpack_${GENLANG}-${ADATE}.pet||${GENLANG} language-pack for Puppy Linux, for any Puppy built from Woof later than Feb. 28, 2012||||" > /root/langpack_${GENLANG}-${ADATE}/pet.specs
  sed -i -e "s%TARGETLANG%${ORIGLANG1}%" /root/langpack_${GENLANG}-${ADATE}/pinstall.sh
  LANG=$ORIGLANG POSTMSG="`pupdialog --background "#80FFFF" --backtitle "Post-install message" --colors --stdout --inputbox "A post-install message is required for the PET. Please translate the following into your own language:
\ZbLanguage pack installed, but requires restart of X to take full effect\ZB" 0 0`"
  if [ "$POSTMSG" ];then
   sed -i -e "s%POSTINSTALLMSG%${POSTMSG}%" /root/langpack_${GENLANG}-${ADATE}/pinstall.sh
  else
   sed -i -e "s%POSTINSTALLMSG%Language pack installed, but requires restart of X to take full effect%" /root/langpack_${GENLANG}-${ADATE}/pinstall.sh
  fi
  cat /tmp/momanager/translations4langpack |
  while read ALINE
  do
   ADIR="`dirname "$ALINE"`"
   mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
   cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
  done
  
  #130503 L18L: rename AppInfo.xml to AppInfo.xml.in for langpack (see also /usr/share/doc/langpack-template/pinstall.sh in Woof)
  sync #130807 L18L
  for AFILE in `ls -1 /root/langpack_${GENLANG}-${ADATE}/usr/local/apps/*/AppInfo.xml | tr '\n' ' '`
  do
   mv $AFILE "${AFILE}.in"
  done
  
  #120926 want to accumulate many .desktop files (not just for installed pkgs), in /usr/share/applications.in...
  mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in
  cp -a -f /usr/share/applications.in/* /root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in/
  cp -a -f /root/langpack_${GENLANG}-${ADATE}/usr/share/applications/* /root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in/
  rm -r -f /root/langpack_${GENLANG}-${ADATE}/usr/share/applications
  pupdialog --background 'yellow' --backtitle "Menu .desktop files" --colors --msgbox "Translated .desktop files are now in \Zb/root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in\ZB, and the translations will be inserted into same-name .desktop files in /usr/share/applications or /usr/local/share/applications when the langpack PET pkg is installed, and when the PPM installs a pkg. However, please do note that you can manually accumulate as many .desktop files in /usr/share/applications.in in your host Puppy system as you want, not just for installed pkgs, and MoManager will copy all of these into the langpack. For example, say that you have translated .desktop files for OpenOffice -- put them into \Zb/usr/share/applications.in\ZB -- it doesn't matter that the Puppy in which the langpack will be installed does not (yet) have OpenOffice installed. This operation has already been performed." 0 0
  
  mv -f /root/langpack_${GENLANG}-${ADATE}/usr/share/desktop-directories /root/langpack_${GENLANG}-${ADATE}/usr/share/desktop-directories.in
  #120313 offer to find more...
  pupdialog --background 'orange' --backtitle "Langpack PET almost done" --colors --yes-label "Build PET" --no-label "Find all" --yesno "The langpack has been assembled in folder /root/langpack_${GENLANG}-${ADATE}, ready to be made into a PET. Click \ZbBuild PET\ZB to do this now. However, if you want, you can click \ZbFind all\ZB to tell MoManager to hunt for any other mo, po, pot, t12s translation files in the system, plus ${ORIGLANG1} hunspell dictionary, and include those in the PET..." 0 0
  if [ $? -eq 1 ];then
   find /usr -type f -name '*.po' -o -name '*.mo' | grep "/${ORIGLANG1}[/_.]" |
   while read ALINE
   do
    ADIR="`dirname "$ALINE"`"
    mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
    cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
   done
   find /usr -type f -name '*.pot' |
   while read ALINE
   do
    ADIR="`dirname "$ALINE"`"
    mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
    cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
   done
   #zigbert uses t12s method. ex: /usr/local/pburn/locals/ru_RU:russian ...
   find /usr/local -type f -name "${ORIGLANG1}_[A-Z][A-Z]:*" |
   while read ALINE
   do
    ADIR="`dirname "$ALINE"`"
    mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
    cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
   done
   #120316 other t12s translations, refer http://bkhome.org/blog/?viewDetailed=02748 ...
   if [ -d /usr/share/locales/${ORIGLANG1} ];then
    mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG1}
    cp -a -f /usr/share/locales/${ORIGLANG1}/* /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG1}/
   fi
   if [ -d /usr/share/locales/${ORIGLANG12} ];then
    mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG12}
    cp -a -f /usr/share/locales/${ORIGLANG12}/* /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG12}/
   fi
   #120316 puppy is usually built with english hunspell dictionary. other languages can be found,
   #refer: http://bkhome.org/blog/?viewDetailed=02750, refer also pinstall.sh of langpack.
   for ONEHUN in `find /usr/share/hunspell -mindepth 1 -maxdepth 1 -type f -name "${ORIGLANG1}*.dic" -o -name "${ORIGLANG12}*.aff" | tr '\n' ' '`
   do
    HUNBASE="`basename $ONEHUN`"
    mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/hunspell
    cp -a -f $ONEHUN /root/langpack_${GENLANG}-${ADATE}/usr/share/hunspell/
    #maybe need symlinks for apps that use myspell, refer to example hunspell-en-us-2.pet ...
    mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/enchant/myspell
    ln -snf ../../hunspell/${HUNBASE} /root/langpack_${GENLANG}-${ADATE}/usr/share/enchant/myspell/${HUNBASE}
    mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/myspell/dicts
    ln -snf ../../hunspell/${HUNBASE} /root/langpack_${GENLANG}-${ADATE}/usr/share/myspell/dicts/${HUNBASE}
   done
   #120317 L18L man pages...
   if [ -d /usr/share/man/${ORIGLANG1} ];then
    mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/man/${ORIGLANG1}
    cp -a -f /usr/share/man/${ORIGLANG1}/man* /root/langpack_${GENLANG}-${ADATE}/usr/share/man/${ORIGLANG1}/
   fi
  fi
  
  sync
  cd /root
  dir2tgz /root/langpack_${GENLANG}-${ADATE}
  tgz2pet /root/langpack_${GENLANG}-${ADATE}.tar.gz
  sync
  pupdialog --background '#8080FF' --backtitle "Langpack PET created" --msgbox "Langpack /root/langpack_${GENLANG}-${ADATE}.pet has been created." 0 0
 ;;
esac

###END###
