#!/bin/bash
#(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 inoot 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.
#130503 L18L: rename AppInfo.xml to AppInfo.xml.in for langpack
#130505 L18L: quick version: caching variables in CACHE/... from 2m to 2s
#130512 acknowledge new translators, deleting /tmp/momanager
#130519 L18L bug fix: instead of APKGNAME use ASCRIPT, DESKFILE, XMLFILE, ABIN; code for sss and menu categories unchanged
#130520 L18L bug fix: multiple scripts for 1 TEXTDOMAIN
#130521 L18L bug fix binaries, update NOCNT,YESCNT
#130522 L18L bug fix 1 line NOXML_XML and multiple scripts
#130525 L18L replace intltool-update by msgmerge
#all following updates by L18L except when otherwise noted
#130602 sort binaries, sort scripts case insensitive by basename
#130603 preferences, create/modify configuration file /root/.config/momanager
#130604 search button added, --empty-- fixed
#130605 check_dates
#130606 bug fix create_mo, ~/.config/momanager edited
#130607 changing all 'MoManager-${ORIGLANG12' to 'MoManager-${transLANG' requested by Bert
#130609 list left and right scripts: Base name:PATH
#130610 use html, css to highlight pattern in search result; list left and right binary executables: Base name:PATH
#130610 search output with context
#130611 configuration simplified
#130612 fix for desk_strings not showing up in editor reported by AbdelAziz
#130613 design for small sreens; WINDOW_WIDTH configurable between 726 an 1360 px
#130620 force console borderless=off because Bert requested search results being closeable
#130806 sync added
#131001 transLANG added to output of search (ex: mo files under transLANG=fr not fr_BE)
#131002 last edited mo file at top of list # Bert's old wish for edit_mo
#131013 delete harmful pot files
#131014 WINDOW_WIDTH no more in preferences
#131015 output directory MOMADIR for MoManager-* files configurable by preferences
#131026 fit for fatdog64 has gettext in /etc; pupdialog needs declaration as dependency
#131028 added animation for translation of Comment in /usr/share/applications/*.desktop 
#131029 support for language=Glade added (-j join existing)
#131104 insert 'export TEXTDOMAIN=' into *.sh.xml.sh (temporary copy of *.sh.xml)
#131110 acknowledge Bert's MM-standalone.pet instead of devx
#131206 make it fatdog compatible, LANGPACK=langpack | langpack_fatdog
#131212 support t12s method
#131219 enable quirky6.0: no check on pupmode
#140101 bugfix thanks zephyr2
#140103 window_width changed, no test on existance of intltool-update, gettext alternative for devx
#140104 LANGPACK=langpack | langpack_fatdog | langpack_quirky
#140223 LANGPACK=langpack | langpack_fatdog only; bug fix for "up-to-date" or "check-needed"
#140227 running  faster
#140228 code cleaning, find fuzzy
#140303 fuzzy bug fix
#140307 find all-fuzzies at start, new sort of scripts that have a mo file, refresh button
#140308 update list of fuzzies for YESMO
#140309 update list of fuzzies for NOMO
#140326 pre-caution: if create_pet then clear cache
#140922 by ASRI # improve icons: stop use /usr/local/lib/X11/mini-icons/, now use gtk icons # improve interface
#141002 by L18L and ASRI # Main window : change width-request of first hbox
#141007 bug fix: fuzzy was NOT shown for "mo file newer than script"
#141008 keep translations from other puppies to make languagepack useable for more than just 1 distro
#141123 bug fix in no_to_yes; avoid message about zero fuzzy
#150308 BK: yaf-splash is deprecated in Quirky (except for the original yaf-splash), use 'popup' (and 'popadd').
#150308 BK: corrections for text in welcome window.
#150308 BK: locale de_DE.UTF-8, translated binary 'proxy-setup', created /root/MoManager-en-pup-tools: 'en' is wrong, $transLANG is wrong.
#150308 BK: edited preferences, changed transLANG to 'fr', exit editor, momanager still on 'de'. only goes to 'fr' after next translation. --fix is kill geany beforehand.
#150309 L18L: bug fix for 141008.
#150309 BK: setting transLANG in $CONFIG is not good. however, since have it, fix for inappropriate locale.
#150309 BK: only put up msg about choice between, say, de and de_DE, once.
#150313 L18L fatdog can operate without langpack, re-enable menu categories for fatdog #TODO: complete and test it
#150314 L18L translate also GenericName in *.desktop (razor menu)
#150404 L18L kill please wait; always create empty pot file for shell scripts and use xgettext -j
#150409 L18L kill "Fuzzy Translations" window and other bug fixes
#150428 change 'INSERT YOUR TRANSLATION HERE' to 'INSERT YOUR TRANSLATION HERE or DELETE THIS TEXT or IGNORE THIS LINE'
#150829 create_a_txz (fatdog package)
#151001 translate also .md files (see function get_prop), use AUTHORSPECS in write.log, some code clean up
#151010 fixed pot for mdview; added path of zigbert's stardustlib
#151022 ASRI: add version information in title bar of main GUI, and many other fixes.
#151108 support mdview option path; t12s_ scripts as functions; no more external scripts
#151230 new hybrid METHODs (e.g. t12s and/or gettext and/or mdview using same TEXTDOMAIN)
#160205 use also subdirs of /usr/share/applications; xgettext --add-comments=i18n; allow translations to English
#160401 MATCH_TEXTDOMAIN
#160410 fix and simpler window for "files which TEXTDOMAIN matches ${MATCH_TEXTDOMAIN}"
#170224 some fixes, refresh button also for TEXTDOMAIN matches
#170616 changed 'rxvt -e dialog' (no utf8) to 'Xdialog' (uses utf8) for fuzzy translations
#170618 strip_po for English, useful for developers; #sort messages by msgid/FILE;  
#170630 code split to functions, tested in easy
#170707 " inserted: [ -f "$MOFILE" ] && FNDMO="$MOFILE" ; create_bin bug : ASCII... fixed; pop_up tarball added:   
#170814 yesmo drop-down configurable; support custom TEXTDOMAINDIR; edit_until_error_free also for bin; more functions; fix single md; rox opens WD
#170815 fix t12s
#181207 fix lastID with t12s
#190118 replace Quirky by Easy, fix initrd_strings for easyos, added boot_strings
#190306 BK: initrd back to SSS (was using gettext).
#200112 BK: fix some text to distinguish between Puppy, EasyOS and fatdog.
#200112 BK: completely replace "isQUIRKY" with "isEASYOS".
#200112c BK: transLANG has to be set to current locale, msg tidied up.
#200317c L18L: headline shorter; generate Xenglish pseudo "translation" for LANG=en
#200325 L18L: always mo for binaries
#200505 L18L: one new TEXTDOMAIN (=MATCH_TEXTDOMAIN) for several old ones; easy-peasy; poedit bug fixed
#200606 jwm (ELF shared) enabled; create all mo files for transLANG=en; n_to_1 fixed 
#200808 preview for n_to_1 added; Fix for launch FROM menu



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


############################################
# Fix for launch FROM menu #200808
FILE="/usr/share/applications/MoManager.desktop"
OLD="Exec=momanager"
NEW="Exec=rxvt --hold --title 'momanager' -e momanager"
if [ "$(grep -m 1 "^$OLD" $FILE)" ]; then
  sed -i "s/${OLD}/${NEW}/" $FILE
  fixmenus
  jwm -restart
  exec $thisSCRIPT reenter
fi
unset FILE OLD NEW
############################################


############################################
#arguments
############################################

thisSCRIPT="$0" #140227
#echo thisSCRIPT=$thisSCRIPT

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

if [ "$2" ]; then
 echo "
 $0 -> $1 -> $2"
 eval "$2"
fi


[ "$searchENTRY" ] || searchENTRY='search term' # content of input field

#lastUPDATEofTHISscript="20` grep -E '^$' -B 1 $0 | head -n 1 | cut -d ' ' -f1 | cut -d '#' -f2`" # sort of version
lastUPDATEofTHISscript="20$(grep -m 1 -E '^$' -B 1 $0 |  cut -d ' ' -f1 | cut -d '#' -f2)" # sort of version,  ex:170707 

TEXTDOMAINDIRVALUE=/usr/share/locale	#190118 added for bin
defaultTEXTDOMAINDIRVALUE=/usr/share/locale


############################################
# functions
############################################

die() { echo "$1"; pop_up "$1"; exit 1; }

kill_all_windows_titled () { kill $(ps H 2>/dev/null | grep "$1" | grep -v 'grep' | awk '{print $1}') 2>/dev/null ; }

pop_up () {

 # popup seems not to work with Easy	
#if [ $POPUPFLAG -eq 1 ];then
 # popup "name=mmpop1 background=#FFB030 level=top|$1" #daemonises
 #else
  yaf-splash -bg orange -text "$1" &
  yPID=$!
 #fi

} #end pop_up


intro () {

 #download woof, to get latest files... no, too difficult, just put up warning... 150308...
 
 #200112... 200317
 TEXT="Welcome, MoManager will help you to create and edit language translations for your country, for many of the applications in Puppy.

Note for English \"only\" developers, MoManager can create translations to the pseudo language 'X english' that is always just English preceeded by 'X '. Thus anyone can test their gettexted scripts.  'X ' is configurable. 
 
Note, MoManager is also used with Fatdog and EasyOS, forks of Puppy.
 
VERY IMPORTANT: You must be currently running the latest woof-CE built Puppy. If your Puppy is even a month old, it is recommended that you check for a later release.
 
If you are currently running the latest Puppy, then click the 'OK' button to continue running MoManager:"
 if [ "$isEASYOS" ];then #200112
  TEXT="Welcome, MoManager will help you to create and edit language translations for your country, for many of the applications in EasyOS.

Note for English 'only' developers, MoManager can create translations to the pseudo language 'X english' that is always just English preceeded by 'X '. Thus anyone can test their gettexted scripts.  'X ' is configurable. 
 
Note, MoManager started life with Puppy Linux, so discussion on the Puppy Forum is relevant. MoManager is also used with Fatdog, a fork of Puppy.
 
VERY IMPORTANT: You must be currently running the latest EasyOS. If your EasyOS is even a month old, it is recommended that you check for a later release. You can check Barry's Blog (bkhome.org/news) for release announcements.
 
If you are currently running the latest ${PUPPY}, then click the 'OK' button to continue running MoManager:"
 fi
 if [ "$isFATDOG" ]; then # another warning for fat dogs 150313
  TEXT="Welcome, many of the applications in Fatdog have already been  translated for your country in fd64-nls_$(cat /etc/fatdog-version).sfs.
 
MoManager will help you to create and edit language translations for the Fatdog special scripts and help files.

MoManager can also create translations to the pseudo language 'X english'. Thus anyone can test their gettexted scripts.  'X ' is configurable.
  
VERY IMPORTANT: You must be currently running a Fatdog version 710 or later and its fd64-nls_710.sfs.
  
If you are currently running this Fatdog and its 'Native Language Support' SFS package , then click the 'OK' button to continue running MoManager:" 
 fi
 export MM1_DLG="<window title=\"MoManager-${lastUPDATEofTHISscript}: welcome\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
  <vbox>
  <text><label>\"$TEXT\"</label></text>
  <hbox>
   <button ok></button>
   <button cancel></button>
  </hbox>
 </vbox>
</window>
"

 if [ "$showINTRO" = "yes" ]; then #130603
  MM1RET="`$GTKDIALOGEXE --program=MM1_DLG`"
  [ "`echo "$MM1RET" | grep 'OK'`" = "" ] && exit 2
 fi #130603

 #131013 delete harmful pot files (they will actually be created)
 cd /usr/share/doc/nls 2>/dev/null
 for d in ffconvert freememapplet_tray get_libreoffice grub4dosconfig  peasyscan pmusic pupmd5sum.sh welcome1stboot.sh
 do rm -r $d 2>/dev/null ; done
 cd - 1>/dev/null #131013

} # end intro


#tooltip title and content of combobox for items that have  a translation file
yesmo () { 
	case "$show_scripts" in
				   ALL) TTT="one item per SCRIPT file"
						toggle_item_per="one item per TEXTDOMAIN"
				   		ln -sf  $CACHE/YESMO_XML_ALL $CACHE/YESMO_XML
						;;
	ONE_per_TEXTDOMAIN)	TTT="one item per TEXTDOMAIN"
						toggle_item_per="one item per script file"
						ln -sf $CACHE/YESMO_XML_ONE $CACHE/YESMO_XML
						;;	
	esac
}


intro_match () { #all or matching only
	             # 200416 check added; easy peasy
	             
  [ "$(cat ${WD}/MATCH_TD_CHECKED 2>/dev/null)" = "checked" ] && ON='ON' || ON='OFF'

  HELP="Input of a TEXTDOMAIN will let appear the next window much faster than without, \nbut you are restricted to the found results for scripts only. 
  "
  HELP="$HELP
 With no input you will get the conventional large window with scripts, menu labels, etc. 
 " # choose MATCH_TEXTDOMAIN ex: fatd for fatdog and fatdoghelp #160401
  TEXT="MoManager will be searching the entire installation
for ANY TEXTDOMAIN 

or

for TEXTDOMAINS just matching
    your following input.
    
      it's easy - peasy:  ☺ "
  [ "$isFATDOG" ] && TEXT="$TEXT input of fatd will find 'fatdog' and 'fatdoghelp'." || TEXT="$TEXT
      input of
        easy
 will find 'easy...' and 'peasy...'.
 In order to find just easy... (without peasy)
              simply
  uncheck 'easy matches peasy' below  ☺"   
  TEXT="${TEXT}

Matching TEXTDOMAIN: "
  Xdialog --help "$HELP" --no-cancel --title MoManager-${lastUPDATEofTHISscript} --check "easy matches peasy" ${ON} --input "$TEXT" 0 0 "$MATCH_TEXTDOMAIN" 2>${WD}/MATCH_TEXTDOMAIN
  case $? in
   0) MATCH_TEXTDOMAIN=$(head -n 1 ${WD}/MATCH_TEXTDOMAIN)
      # read MATCH_TEXTDOMAIN < ${WD}/MATCH_TEXTDOMAIN
      CHECKED=$(tail -n 1 ${WD}/MATCH_TEXTDOMAIN) ;;
   *) MATCH_TEXTDOMAIN= ;;
  esac
  #170224 force same file for 'Cancel' and 'empty OK'
  echo -n "$MATCH_TEXTDOMAIN" > ${WD}/MATCH_TEXTDOMAIN
  echo -n "$CHECKED"          > ${WD}/MATCH_TD_CHECKED

  combo_width

} #end intro_match


create_sample_t12s () {

 #create a sample script file ssf for t12s method
 ssf=/usr/bin/hello_t12s
 if [ ! -f $ssf ]; then
  echo '#!/bin/sh
# define TEXTDOMAIN same way as with gettext' > $ssf
  echo 'export TEXTDOMAIN=hello_t12s' >> $ssf
  cat >> $ssf <<EOF
 
# define translation file LOCALES 
LOCALES=/usr/share/locales/\${LANG%_*}/\$TEXTDOMAIN

# Load translation file if existant (at correct location)
[ -f \$LOCALES ] && . \$LOCALES

# some small phrases:
echo "------------------------------------"
echo \${_M_:-hello world}

x="\${_M_:-crazy}"

echo "This may work or not: \${_M_:-hello \$x world}"

echo "But this does work: \${_M_:-hello \$_M_3 world}"

echo "------------------------------------
that's it."

echo "A new unnumbered variable: \${_M_:-Hi fans!}"

echo "Another new unnumbered variable: \${_M_:-Hello fans!}"

EOF
  chmod +x $ssf
  chmod +w $ssf
 fi 

} #/end create_sample_t12s 


init_sys () {
	
 #check syntax
 #local T S E
 T=grub4dosconfig
 S="$(which ${T})"
 E="export TEXTDOMAIN=${T}"  #nothing else valid at this line
 grep "^${E}$" ${S} >/dev/null || sed -ie "s/${E}/${E}\n/" ${S}  #200707
 
 #check tools
 local F FILES MISSINGFILE
 MISSINGFILE=""
 FILES="xgettext msginit msgmerge msguniq msgfmt msgunfmt urxvt"
 for F in $FILES; do [ "$(which $F)" ] || MISSINGFILE="${MISSINGFILE}$F "; done
 if [ "$(which pupdialog)" ]; then #131026
  :
 else
  Xdialog --title "-${lastUPDATEofTHISscript}: Abort" --infobox "pupdialog has not been found here" 0 0 10000 #131026
  exit 1 #131026
 fi #131026
 if [ "$MISSINGFILE" ];then
  pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, these needed applications are missing: \n\n\Zb${MISSINGFILE}\ZB \n\nThe \Zbdevx\ZB SFS normally has these, but it must be incomplete. \nOr use Bert's i18n-tools or install package gettext. Aborting." 0 0 #140103 gettext package will also do it
  exit 1
 fi
 POPUPFLAG=0  #150308
 [ `which popup 2>/dev/null` ] && POPUPFLAG=1
 [ `which popadd 2>/dev/null` ] || POPUPFLAG=0
 GTKDIALOGEXE="gtkdialog"
 [ "`which gtkdialog4`" ] && GTKDIALOGEXE="gtkdialog4"
 ADATE="`date +%Y%m%d`" #ex: 20120205
 WINICON="gtk-preferences"; HELPICON="gtk-index" #gtk-info


 POEDITOR="`which poeditor 2>/dev/null`"
 [ "$POEDITOR" ] || POEDITOR="`which poedit 2>/dev/null`"


 # language 
 #150309 moved up
 ORIGLANG=$LANG
 ORIGLANG1="`echo -n $ORIGLANG | cut -f 1 -d '_'`"  #ex: de
 ORIGLANG12="`echo -n $ORIGLANG | cut -f 1 -d '.'`" #ex: de_DE
 # transLANG is used and can be set to one of these in config

 # enable also for English now, already working in Fatdog #170618
 #if [ "$ORIGLANG1" = "en" -a ! "$isFATDOG" ];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
  # rm -f $CONFIG #150308 has set transLANG=en, which is wrong!
  # exit 1
 #fi

 if [ "`echo -n $ORIGLANG | grep -i 'utf'`" = "" ];then
  pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, your \Zblocale\ZB ($ORIGLANG 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

 #some variables (they are CONSTANT)
 ISIN=…     #printable character to indicate mo file newer than script
 NOTIN=↻	#printable character to indicate mo file older than script
 FUZZIN=░	#printable character to indicate mo file containing "fuzzy" #140228
 SEPARATOR=→  # as in ex: …askpass→/usr/sbin/askpass (de askpass.mo WOOF)
 HIGH_ON='[01;31m[K'
 HIGH_OFF='[m[K'  #130611 
 translateNOTE='INSERT YOUR TRANSLATION HERE or DELETE THIS TEXT or IGNORE THIS LINE'

 # working directories
 WD=/tmp/momanager
 [ -d $WD ] || mkdir -p $WD    #140308
 CACHE=$WD/cache
 mkdir -p $CACHE #130505
 [ -d $CACHE ] || mkdir -p $CACHE 
 cd $WD
 
# #open working directory in ROX-Filer
# rox -D $WD 
# rox -d $WD  #170814
#### cd $WD #170224-2
# it is opened and closed by buttons now  #200808


 #distro
 isFATDOG=
 isEASYOS=
 read LINE < /etc/issue
 [ "${LINE:0:6}" = "Fatdog" ] && isFATDOG=true
 #[ "${LINE:0:6}" = "Quirky" ] && isQUIRKY=true #200112 quirky is retired.
 [ "${LINE:0:4}" = "Easy" ]   && isEASYOS=true #190115 replace Quirky by Easy

 #131206 some distro dependant texts
 LANGPACK='langpack'
 PUPPY='Puppy'
 [ "$isEASYOS" ] && PUPPY=EasyOS
 TRANSLATE="fully translate ${PUPPY}"
 if [ "$isFATDOG" ]; then
  LANGPACK='langpackFatdog'
  PUPPY='Fatdog'
  TRANSLATE="add translations for ${PUPPY}"
  [ -d /root/.packages/builtin_files ] || { mkdir /root/.packages ; ln -s /var/log/packages /root/.packages/builtin_files ; } #160205
 fi

 # dir2tgz	
 if [ "`which dir2tgz 2>/dev/null`" ]; then
  :   # use script dir2tgz
 else # rewritten for fatdog:
  dir2tgz () {
   [ $1 ] || die 'Usage: # dir2tgz <name of directory>/('
   DIRNAME="${1%%/*}" # last slash removed
   DIRNAME=${DIRNAME#*/} # basename
   [ -d $DIRNAME ] || die "Error: $DIRNAME not found. Must open terminal in same directory."
   tar -c -f ${DIRNAME}.tar ${DIRNAME}/
   [ $isFATDOG ] && xz ${DIRNAME}.tar || gzip --force ${DIRNAME}.tar
   sync
  }
  export dir2tgz  
 fi

 #misc
 export LANG=C
 . /etc/rc.d/PUPSTATE

 #if [ "$isFATDOG" ]; then #140101
 #if [ "$isFATDOG" -o "$isQUIRKY" ]; then #140104

# if [ "$isQUIRKY" ]; then #150313
  #131206 base langpack from puppy required ex: langpack_es
#  if [ "`ls /root/.packages/langpack_${transLANG}-* 2>/dev/null`" = "" ] ; then
   #pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, this needed basic langpack from puppy is missing: \Zblangpack_${transLANG}\ZB. The \Zbcommon repository\ZB normally has this PET. Aborting." 0 0

   #exit 1 #190118 no need for any langpack.pet
#   :
#  fi #131206
# fi #140101


 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
 ###wow exit 1 ###why that??? $HOME/.packages/builtin_files is existing
 #fi #131219
 ppPTN="s%${PATHPREFIX}%%" # not used anymore

 create_sample_t12s	 #buggy functions 



} #end init_sys



langpack_button () {   #help button for PET langpack...

 GENLANG="$ORIGLANG1"
 [ "$TRANSLANG" ] && GENLANG="$TRANSLANG"
 if [ "$isFATDOG" ]; then
  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 Fatdog, 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>GREEN button</b> in the main window of MoManager, a <b>langpack</b> package will be created with all of the translations. Then, all that you have to do is send it to me (L18L) so that I can do some tests post it to Fatdog's developers. and they might put it into next version of fd64-nls.

This will be extremely easy to update. Whenever you have added new translations, or edited existing ones, just click the GREEN button, and a new langpack package will be created. It will have a name like <b>langpack_${GENLANG}-${ADATE}</b>, and be in the $MOMADIR folder (as well as an expanded directory so that you can see what is in it). Then just upload it anywhere and send the link to me, <b>L18L</b> per PM in forum."
 elif [ "$isEASYOS" ];then #200112
  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 EasyOS, 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:
German (de):  L18L
French (fr):  esmourguit

There are some very old translation PETs created by these guys:
Danish (da):  maans
Greek (el):   kounelii
Italian (it): vicmz (temporary)
Dutch  (nl):  Bert
Polish (pl):  robwoj44
Portuguese (pt): vicmz
Russian (ru): rodin.s
Spanish (es): vicmz"
 else
  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 one of the woof-CE maintainers to 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).

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

Note: some of those langpacks are very old, and the creator maybe not active any more."
 fi
 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>'
 PETHELP_XML="<button tooltip-text=\"Help for momanager.\">
<input file stock=\"gtk-help\"></input>
<action type=\"launch\">DLG_HELP_PET</action></button>"

} #end langpack_button


nomo_yesmo () { #find all gettext'ed scripts...with and without mo...use cache

 if [ ! -f $CACHE/GETTEXTSCRIPTS ]; then
  FIND_IN=' /etc /bin /sbin /usr/bin /usr/sbin /usr/share /usr/local ' 
  
  [ "$isFATDOG" ] || FIND_IN="$FIND_IN /root/my-applications /usr/X11R7 /usr/lib/gtkdialog"  #151010 added path of stardustlib



###190118
  FIND_IN='/bin /sbin /usr/bin /usr/sbin /usr/local '

  [ "$isEASYOS" ] && FIND_IN="$FIND_IN /etc/rc.d /root/my-applications/bin /usr/share/doc"

  [ "$isFATDOG" ] && FIND_IN="$FIND_IN /etc /usr/share "
  
  [ ! "$isFATDOG" -a ! "$isEASYOS" ] && FIND_IN="$FIND_IN /root/my-applications /usr/X11R7 /usr/lib/gtkdialog"
###/190118

### 200416 match easy not peasy: STAR='[^ ]*' or ''
  read CHECKED 2>/dev/null < ${WD}/MATCH_TD_CHECKED
  [ "$CHECKED" = "checked" ] && STAR='[^ ]*' || STAR=
  #echo CHECKED=$CHECKED

  find  `echo -n $FIND_IN` -maxdepth 4 -type f -print0 | xargs -0 grep --files-with-matches "^export TEXTDOMAIN=${STAR}${MATCH_TEXTDOMAIN}" | sed -e 's% %SPACECHAR%g' > $CACHE/GETTEXTSCRIPTS #170224 .* inserted #170616 changed .* to [^ ]

  #append files-with-matches '^%%textdomain ' (.md files)
  find /etc /usr/bin /root /usr/share /usr/local -maxdepth 4 -type f -name *.md -print0 | xargs -0 grep --files-with-matches "^%%textdomain ${STAR}${MATCH_TEXTDOMAIN}" | sed -e 's% %SPACECHAR%g' >> $CACHE/GETTEXTSCRIPTS 

  sort_by_basename $CACHE/GETTEXTSCRIPTS #130602 sort by basename

 fi

 GETTEXTSCRIPTS="`cat $CACHE/GETTEXTSCRIPTS `" #130505
 if [ ! -f ${CACHE}/NOMO_XML  ]; then # create lists just once
  echo "Please wait, building cache, scanning files...
"
  #find all matching .mo files...
  YESCNT=0; NOCNT=0; YESMO_XML=""; NOMO_XML=""
  for AGTS in $GETTEXTSCRIPTS # time real  58.7s single core 1.5GHz - 11.8 sec now 2core 1.8GHz
  do
   case $AGTS in *\/\.*) continue ;; esac ##160205 no hidden files
   #xAGTS="`echo -n $AGTS | sed -e 's%SPACECHAR% %g'`"
   xAGTS="${AGTS//SPACECHAR/ }" #140227 just a bit faster 
   
   #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.
   # 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.

   #shorter
   TEXTDOMAINVALUE="`grep -m 1 '^export TEXTDOMAIN=' "$xAGTS"`"
   TEXTDOMAINVALUE="${TEXTDOMAINVALUE#*=}"
   TEXTDOMAINVALUE="${TEXTDOMAINVALUE/\\\t/ }"
   TEXTDOMAINVALUE="${TEXTDOMAINVALUE%% *}" #140227 just another bit faster

   # mdview has %%textdomain textdomainvalue
   [ "$TEXTDOMAINVALUE" ] || TEXTDOMAINVALUE="`grep  -m 1 '^%%textdomain ' "$xAGTS" | cut -f 2 -d ' ' | tr '\t' ' ' | cut -f 1 -d ' '`" 

   TEXTDOMAINVALUE="${TEXTDOMAINVALUE%% *}"

   #BK
   #want to know if from Woof or a builtin pkg or later-installed pkg...
   #BASExAGTS="`basename "$xAGTS"`"
   BASExAGTS="${xAGTS##*\/}" #140227 faster
   xPTN=" ${BASExAGTS}$"
   #PATHxAGTS="`dirname "$xAGTS"`"
   PATHxAGTS="${xAGTS%\/*}" #140227 faster
   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"`"
     CONFIRM="` sed -e 's%^ %/%' /root/.packages/builtin_files/${AAA} | tr -d '\n' | grep "$xAGTS"`" #140227 faster
     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++++++++++++++++++++++++++++++++++++++++++++
   if [ ! "$aPKGNAME" ]; then #140307
    aPKGNAME="`grep -m 1 "$zPTN" /root/.packages/*.files 2>/dev/null `"
    aPKGNAME="${aPKGNAME%%:*}"; aPKGNAME="${aPKGNAME##*\/}"; aPKGNAME="${aPKGNAME//.files/}"
    #test if user-installed pkg. 120308++++++++++++ sed is not exactly emulated +++++++++++++
   fi
   [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${xAGTS}" ] && aPKGNAME="WOOF" #file is in Woof.
   [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
   [ "$aPKGNAME" = "UNKNOWN" ] && [ "`grep -m 1 ${xPTN} /var/log/packages/*`" ] && aPKGNAME=FATDOG  #151001

   #find mo files for both, LL    and for LL_RR  (locale=ll_RR)
   #         ex:  ORIGLANG1=de ORIGLANG12=de_DE 

   FNDMO=""

   #if [ -f "$TEXTDOMAINDIRVALUE/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo" ];then
   # FNDMO="$TEXTDOMAINDIRVALUE/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
   # TRANSLANG=$ORIGLANG12
   #else
   # if [ -f "$TEXTDOMAINDIRVALUE/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo" ];then
   #  FNDMO="$TEXTDOMAINDIRVALUE/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
   #  TRANSLANG=$ORIGLANG1
   # fi
   #fi
   
   #no, we are using transLANG now
   
   MOFILE="$defaultTEXTDOMAINDIRVALUE/${transLANG}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
   [[ -f "$MOFILE" ]] || MOFILE="$(find /usr -print0 | grep -m 1 -EzZ $transLANG/LC_MESSAGES/${TEXTDOMAINVALUE}.mo$)" #170814
      
   [ -f "$MOFILE" ] && FNDMO="$MOFILE"
  
   # 151108 much simpler for t12s method
   if [ -z "$FNDMO" ]; then 
    MOFILE=${defaultTEXTDOMAINDIRVALUE}s/${transLANG}/${TEXTDOMAINVALUE}
    [ -f "${MOFILE}" ] && FNDMO="${MOFILE}"
   fi
    
   if [ "$FNDMO" ];then
    #130605 check dates: FNDMO > xAGTS: + ok, - needs check
    dateMO="`ls -l --time-style=+%Y%m%d $FNDMO | awk '{print $6}' `"
    dateSCRIPT="`ls -l --time-style=+%Y%m%d $xAGTS | awk '{print $6}' `"

    xAGTS="${xAGTS##*/}${SEPARATOR}${xAGTS}" #130609 base name at 1st place
    #if [ "$dateMO" -ge "$dateSCRIPT" ]; then
    if [ "$dateMO" -gt "$dateSCRIPT" ]; then #190118
     [ "`grep -m 1 "^${TEXTDOMAINVALUE}.po:#, fuzzy" $CACHE/fuzzies 2>/dev/null`" ] && xAGTS="${FUZZIN}${xAGTS}" || xAGTS="${ISIN}${xAGTS}" #140228
    else
     xAGTS="${NOTIN}$xAGTS" #130605
    fi

    #if [ "$isFATDOG" -o "$isQUIRKY" ]; then #take just those files that are not in basic langpack #140104
###    if [ "$isQUIRKY" ]; then #take just for quirky #150313
###     [  "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ]  && continue
###    fi
###190118

    #count found mo files
    let YESCNT=YESCNT+1

    #build combobox
    YESMO_XML="${YESMO_XML}<item>${xAGTS} (${transLANG} ${TEXTDOMAINVALUE}${DOTMO} ${aPKGNAME})</item>
"  #131212

    echo "$FNDMO" >> $WD/translations4langpack
   else
    xAGTS="${xAGTS##*/}${SEPARATOR}${xAGTS}" #130609 base name at 1st place
    let NOCNT=NOCNT+1
    #NOMO_XML="${NOMO_XML}
#<item>${xAGTS} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>"
    NOMO_XML="${NOMO_XML}<item>${xAGTS} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>
" #fixed so that last line is also processed #200606
   fi
   done
   
   echo -n "$NOMO_XML"  > $CACHE/NOMO_XML  #20130505
   echo -n "$YESMO_XML" | sort --ignore-case > $CACHE/YESMO_XML_ALL
   echo -n "$YESMO_XML" | sort -k 3,3 --ignore-case -u > $CACHE/YESMO_XML_ONE #20170728
   echo -n "$YESCNT"    > $CACHE/YESCNT    #20130505
   echo -n "$NOCNT"     > $CACHE/NOCNT     #20130505
   yesmo
   
  else
   NOMO_XML="`cat $CACHE/NOMO_XML`"   #20130505
   yesmo
   YESMO_XML="`cd $CACHE;SEQ="$FUZZIN $NOTIN $ISIN";for f in $SEQ;do grep $f YESMO_XML > $f; done && cat $SEQ;cd - >/dev/null`" #20140307
   [ "$YESMO_XML" ] || YESMO_XML="`cat $CACHE/YESMO_XML`" #20170223
   YESCNT="`cat $CACHE/YESCNT`"       #20130505
   NOCNT="`cat $CACHE/NOCNT`"         #20130505
  fi

  if [ "$YESMO_XML" ];then
   YESMO_XML="<combobox tooltip-text=\"$TTT\"  width-request=\"$COMBOyesWIDTH\">
   <variable>YESMO_COMBO</variable>${YESMO_XML}</combobox>" #130613
   #launch check on fuzzy 
   if [ "$PARAM1" != "createApet"  ]; then
    if [ ! -f $CACHE/fuzzies ]; then
     create_po_file_from "$CACHE/YESMO_XML"
     fuzzy_find
     LANG=$ORIGLANG exec $thisSCRIPT reenter
    fi 
   fi
  else
   YESMO_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>EMPTYYESMO_COMBO</variable><item>--empty--</item></combobox>"
  fi

  if [ "$NOMO_XML" ];then
   NOMO_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>NOMO_COMBO</variable>${NOMO_XML}</combobox>"
  else
   NOMO_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>EMPTYNOMO_COMBO</variable><item>--empty--</item></combobox>"
  fi

 #help buttons...  # for mo files
 MO_HELP_MSG="Puppy "; [ $isFATDOG ] && MO_HELP_MSG="Fatdog "
 [ "$isEASYOS" ] && MO_HELP_MSG="EasyOS" #200112
 MO_HELP_MSG="$MO_HELP_MSG 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."

 [[ "$show_scripts" = "ONE_per_TEXTDOMAIN" ]] &&  YESMO_HELP_MSG="$MO_HELP_MSG

The drop-down list is a list of <b>TEXTDOMAIN</b>s for which there is a mo translation file in your language.

The drop-down list has extra information in brackets, in the format <b>(language TEXTDOMAIN package)</b>. Note the sort order, please. The list is sorted by TEXTDOMAIN."

 [[ "$show_scripts" = "ALL" ]] &&  YESMO_HELP_MSG="$MO_HELP_MSG
 
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." 

YESMO_HELP_MSG="$YESMO_HELP_MSG

A mo translation file in your language (${ORIGLANG12}) is at $TEXTDOMAINDIRVALUE/${ORIGLANG12}/LC_MESSAGES/ or $TEXTDOMAINDIRVALUE/${ORIGLANG1}/LC_MESSAGES/. You may select one of the TEXTDOMAINs, 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><variable>DLG_HELP_YESMO</variable></button>
</hbox></vbox></window>"

 YESMOHELP_XML="<button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_YESMO</action></button>"
 NOMO_HELP_MSG="$MO_HELP_MSG

The drop-down list is a list of scripts for which there is NOT a 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."

if [ "$transLANG" != "en" ]; then
NOMO_HELP_MSG="$NOMO_HELP_MSG
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."
else #200606
NOMO_HELP_MSG="$NOMO_HELP_MSG

Clicking the <b>Create</b> button will simply create automatically the pseudo translation to Xenglish for all of the files in the drop-down list."
fi

 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>
 <variable>DLG_HELP_NOMO</variable>
 </hbox></vbox></window>"

 NOMOHELP_XML="<button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_NOMO</action></button>"

#### help for n_to_1
 NUM="$(ls *.pot 2>/dev/null | wc -w)"   # check number

 N_1_HELP_MSG="$MO_HELP_MSG
 
 Each TEXTDOMAIN is a mo file.
 Hard to handle when their number is growing and growing... 
 Uniting some of them is easy.
 Existing translations are retained all in one mo file.
 "
 if [ ! -f ${WD}/MOsize ]; then N_1_HELP_MSG="$N_1_HELP_MSG
 $NUM → 1 button will just check and 
 show number of messages and file sizes. "
 else N_1_HELP_MSG="$N_1_HELP_MSG
 $NUM → 1 button has just checked and can
 show number of messages and file sizes now."
 fi
 if [ -f ${WD}/MOsize ]; then
   read MOsize < ${WD}/MOsize
   read MOsizeNEW< ${WD}/MOsizeNEW
   read MSGs < ${WD}/MSGs
   read MSGsNEW < ${WD}/MSGsNEW
   read TD_NEW < ${WD}/TD_NEW
   NUM="$(ls *.pot 2>/dev/null | wc -w)"   # check number
   N_1_HELP_MSG="$N_1_HELP_MSG

       ACTUAL: $NUM mo files   $MOsize bytes  and  $MSGs  messages  
         
         NEW:  1  ${TD_NEW}.mo   $(cat ${WD}/MOsizeNEW)  bytes  and  $(cat ${WD}/MSGsNEW) messages  
    
Close this window and press $NUM → 1 button to make it happen."
 fi
 
 export DLG_HELP_N_1="<window resizable=\"false\" title=\"MoManager: Help unite mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${N_1_HELP_MSG}\"</label><variable>VAR_HELP_N_1</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_N_1</action></button>
 <variable>DLG_HELP_N_1</variable>
 </hbox></vbox></window>"

 N_1_HELP_XML="<button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_N_1</action></button>"

} #end nomo_yesmo


nobin_yesbin () { ########Binary executables#######
 
  MATCH_TEXTDOMAIN="$(cat ${WD}/MATCH_TEXTDOMAIN)"
 if [ ! -f $CACHE/YESBIN_XML ] ; then #130505
  #support a limited number of binary executables that have .po(t ?)files in /usr/share/doc/nls
  #also limited for 'LSB executable' #200325
  YESCNT=0 ; NOCNT=0 ; YESBIN_XML="" ; NOBIN_XML=""
  #for ANLSDIR in `ls -1 /usr/share/doc/nls | tr '\n' ' '` # time 6.5s
  mkdir -p /usr/share/doc/nls
  for ANLSDIR in `ls -1 /usr/share/doc/nls | tr '\n' ' '` # 130602 sort
  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" >> $WD/translations4langpack
     done
                                                                                [[ "$ANLSDIR" =~ "$MATCH_TEXTDOMAIN" ]] || continue #200325 
 
     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 # jwm is LSB shared object #200606
      if [ "$(file "$BINEXEC" ~= " ELF ")" != "" ];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='$TEXTDOMAINDIRVALUE' #120308
       PREFIXLOCALEDIR="$TEXTDOMAINDIRVALUE" #120308 #190118


       #if [ -f $TEXTDOMAINDIRVALUE/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
		#FNDMO="$TEXTDOMAINDIRVALUE/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
        #TRANSLANG=$ORIGLANG12
       #else
        #if [ -f $TEXTDOMAINDIRVALUE/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
		#FNDMO="$TEXTDOMAINDIRVALUE/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
         #TRANSLANG=$ORIGLANG1
        #fi
       #fi
       
		#we are using transLANG now #170701
		MOFILE="$TEXTDOMAINDIRVALUE/${transLANG}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
		[ -f $MOFILE ] && FNDMO="$FINDMO $MOFILE"
        
       #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=$transLANG
        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
        BINEXEC="${BINEXEC##*/}${SEPARATOR}${BINEXEC}" #130610 base name at 1st place

        #[ "$isFATDOG" -a "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ] && continue #131206 Fatdog: take just those files that are not in basic langpack #140101

###        if [ "$isFATDOG" -o "$isQUIRKY" ]; then #take just those files that are not in basic langpack #140104
###         [ "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ] && continue
###        fi
###190118

        let YESCNT=YESCNT+1
        YESBIN_XML="${YESBIN_XML}
<item>${BINEXEC} (${TRANSLANG} ${TEXTDOMAINVALUE}.mo ${aPKGNAME})</item>"
        echo "${PREFIXLOCALEDIR}/${TRANSLANG}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo" >> $WD/translations4langpack #120308
       else
        BINEXEC="${BINEXEC##*/}${SEPARATOR}${BINEXEC}" #130610 base name at 1st place
        let NOCNT=NOCNT+1
        NOBIN_XML="${NOBIN_XML}
<item>${BINEXEC} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>"
       fi
    
      fi
     fi
    fi
   done
   echo "$YESBIN_XML" | sort --ignore-case --field-separator=' ' --key=3 > $CACHE/YESBIN_XML #130602
   echo "$NOBIN_XML"  | sort --ignore-case --field-separator=' ' --key=3 > $CACHE/NOBIN_XML #130602
  fi #130505
  YESBIN_XML="`cat $CACHE/YESBIN_XML`"
  NOBIN_XML="`cat $CACHE/NOBIN_XML`"
  if [ "$YESBIN_XML" ];then
   YESBIN_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>YESBIN_COMBO</variable>${YESBIN_XML}</combobox>"
  else
  YESBIN_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>EMPTYYESBIN_COMBO</variable><item>--empty--</item></combobox>"
  fi
  if [ "$NOBIN_XML" ];then
   NOBIN_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>NOBIN_COMBO</variable>${NOBIN_XML}</combobox>"
  else
   NOBIN_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>EMPTYNOBIN_COMBO</variable><item>--empty--</item></combobox>"
  fi

  #help buttons...
  BIN_HELP_MSG="MoManager provides translation support for a limited number of binary executables."
  YES_MSG="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 ${transLANG1} 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."
  NO_MSG="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.
"
  
 if [ ! "$isFATDOG" ]; then 


  YESBIN_HELP_MSG="$BIN_HELP_MSG
  
$YES_MSG

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 $TEXTDOMAINDIRVALUE.

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 Package Manager."
 else
  YESBIN_HELP_MSG="$BIN_HELP_MSG
  
Translation support is provided by Fatdog via the <b>nls</b> package. Anything available on the web is already included in the recent SFS package.
  
For compatibility with Puppy you can put <b>pot</b> files into your file system and create/edit translations, e.g. for miredo put miredo.pot at
 /usr/share/doc/nls/miredo/${transLANG}/LC_MESSAGES/
Thus you can use MoManager to <b>edit</b> the ${transLANG} translation for the binary executable miredo."
 fi
 export DLG_HELP_YESBIN="<window resizable=\"false\" title=\"Help edit mo file for binary executables\" 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 stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_YESBIN</action></button>"

 if [ ! "$isFATDOG" ]; then
  NOBIN_HELP_MSG="$BIN_HELP_MSG
  
$NO_MSG

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 $TEXTDOMAINDIRVALUE.

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 Package Manager."
 else
  NOBIN_HELP_MSG="$BIN_HELP_MSG

Translation support is provided by Fatdog via the <b>nls</b> package. Anything available on the web is already included in the recent SFS package.
  
For compatibility with Puppy you can put <b>pot</b> files into your file system and create/edit translations, e.g. for miredo put miredo.pot at
 /usr/share/doc/nls/miredo/${transLANG}/LC_MESSAGES/
Thus you can use MoManager to <b>create</b> the ${transLANG} translation for the binary executable miredo (pot file is to be found in the source tree under po).

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 $TEXTDOMAINDIRVALUE.

There are many other binary executable applications in Fatdog that do not need to be  managed by MoManager simply because recent translations are already included in Fatdog's <b>nls</b> package."
  
 fi
 export DLG_HELP_NOBIN="<window resizable=\"false\" title=\"Help create mo file for binary executables\" 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 stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_NOBIN</action></button>"

} #end nobin_yesbin


noxml_yesxml () {		#######XML#######

 if [ ! -f $CACHE/YESXML_XML ] ; then #130505
  #search $PATHPREFIX to avoid devx files...
  YESXML_XML='' ; NOXML_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 # time 6.2s
  do
   #AXMLFILE="`echo -n "$AXMLFILE" | sed -e 's%SPACECHAR% %g'`"
   AXMLFILE="${AXMLFILE//SPACECHAR/ }" #140227 faster 
 
   #[ "`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.
   #140227 never needed this (experience)
   [ "`echo -n "$AXMLFILE" | grep 'apps/ROX-Filer/'`" != "" ] && continue #120307 ROX-Filer now translated via /usr/share/doc/nls/ROX-Filer/ROX-Filer.pot
 
   #want to know if from Woof or a builtin pkg or later-installed pkg...
   #BASEAXMLFILE="`basename "$AXMLFILE"`"
   BASEAXMLFILE="${AXMLFILE##*\/}" #140227 faster
 
   xPTN=" ${BASEAXMLFILE}$"
   #PATHAXMLFILE="`dirname "$AXMLFILE"`"
   PATHAXMLFILE="${AXMLFILE%\/*}" #140227 faster
 
   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"`"
     CONFIRM="`sed -e 's%^ %/%' /root/.packages/builtin_files/${AAA} | 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}" >> $WD/translations4langpack
   else
    NOXML_XML="${NOXML_XML}
<item>${AXMLFILE} (${aPKGNAME})</item>"
   fi
  done
  echo $YESXML_XML > $CACHE/YESXML_XML  #130505
  #echo $NOXML_XML > $CACHE/NOXML_XML    #130505
  echo -n "$NOXML_XML" > $CACHE/NOXML_XML    #130522
 else #130505
  YESXML_XML="`cat $CACHE/YESXML_XML`" #130505
  NOXML_XML="`cat $CACHE/NOXML_XML`"   #130505
 fi #130505

 if [ "$YESXML_XML" ];then
  YESXML_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>YESXML_COMBO</variable>${YESXML_XML}</combobox>"
 else
  YESXML_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>EMPTYYESXML_COMBO</variable><item>--empty--</item></combobox>"
 fi
 if [ "$NOXML_XML" ];then
  NOXML_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>NOXML_COMBO</variable>${NOXML_XML}</combobox>"
 else
  NOXML_XML="<combobox width-request=\"$COMBOnoWIDTH\"><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>'
 YESXMLHELP_XML="<button><input file stock=\"gtk-help\"></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>'
 NOXMLHELP_XML="<button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_NOXML</action></button>"

} #end noxml_yesxml


nosss_yessss () { #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=""
 mkdir -p /usr/share/sss
 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" >> $WD/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}" >> $WD/translations4langpack
  else
   NOSSS_XML="${NOSSS_XML}
<item>${ASSSDOMAIN}</item>"
  fi
 done
 if [ "$YESSSS_XML" ];then
  YESSSS_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>YESSSS_COMBO</variable>${YESSSS_XML}</combobox>"
 else
  YESSSS_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>EMPTYYESSSS_COMBO</variable><item>--empty--</item></combobox>"
 fi
 if [ "$NOSSS_XML" ];then
  NOSSS_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>NOSSS_COMBO</variable>${NOSSS_XML}</combobox>"
 else
  NOSSS_XML="<combobox width-request=\"$COMBOnoWIDTH\"><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) in the boot-partition. When the locale is changed in QuickSetup, the initrd is opened up and the scripts translated.

<b>boot_strings</b>
These are translations for Syslinux and reFind boot-manager menus in the boot-partition.

<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>'
 YESSSSHELP_XML="<button><input file stock=\"gtk-help\"></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>'
 NOSSSHELP_XML="<button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_NOSSS</action></button>"

} #end nosss_yessss


combo_width () {
 
 local MAX_WIDTH
 local MATCH_TEXTDOMAIN="$(cat ${WD}/MATCH_TEXTDOMAIN 2>/dev/null)"
 
 WINDOW_WIDTH=$((`xwininfo -root | grep Width: | cut -d ':' -f2` - 148)) 
 
# MAX_WIDTH=960 ; [[ "$MATCH_TEXTDOMAIN" ]] && MAX_WIDTH=640
 MAX_WIDTH=960 ; [[ "$MATCH_TEXTDOMAIN" ]] && MAX_WIDTH=820

 [[ $WINDOW_WIDTH -gt $MAX_WIDTH ]] && let WINDOW_WIDTH=MAX_WIDTH
 #echo WINDOW_WIDTH=$WINDOW_WIDTH

# if [[ "$MATCH_TEXTDOMAIN" = "" ]]; then # 2 columns
  #echo 2 columns
  let COMBOnoWIDTH=WINDOW_WIDTH/2-52 #edit
  let COMBOyesWIDTH=WINDOW_WIDTH/2-42    #create
# else
  #echo 1 column
#  let COMBOnoWIDTH=WINDOW_WIDTH-18
#  let COMBOyesWIDTH=WINDOW_WIDTH
# fi
  
 #echo WINDOW_WIDTH=$WINDOW_WIDTH
 #echo COMBOnoWIDTH=$COMBOnoWIDTH
 #echo COMBOyesWIDTH=$COMBOyesWIDTH
 
} #end combo_width


config () {

 CONFIG=$HOME/.config/momanager #130603
 FIRSTRUN=0 #150309
 if [ ! -f $CONFIG ];then
  FIRSTRUN=1 #150309
  echo "########## just edit values between = and #   
showINTRO=yes                 # anything other than yes will skip the intro

transLANG=${ORIGLANG1} 		        # ${ORIGLANG1} or ${ORIGLANG%.*} #150309
Xenglish='X '                 # pseudo translation 'Help' -> 'X Help' 

myEMAIL=fido@localhost        # used when create a mo file
CONTEXT_BEFORE=1              # lines to show before found search term
CONTEXT_AFTER=1               # lines to show after found search term
CONS_WIDTH=90                 # number of characters
CONS_HEIGHT=20                # number of characters

MOMADIR=$HOME/MOMA/$transLANG # (existing or not) directory stores resulting files

SORTby=FILE						# default	
#SORTby=msgid					# toggle

# combobox for scripts that DO have a mo file
# note different help files
show_scripts='ALL'					 # default old way 
#show_scripts='ONE_per_TEXTDOMAIN'   # alternative way

"  > $CONFIG
   . $CONFIG
 fi
 
 [[ "$(grep 'Xenglish=' $CONFIG)" ]] || echo "
Xenglish='X '                  # pseudo translation 'Help' -> 'X Help'
 " >> $CONFIG   #200317

 #200112c this needs to be looked at again, however for now just fix the msg...
 #150309 do not allow transLANG to be changed to anything other than current locale
 # (note, if was allowed, would have to check /usr/lib/locale has it, but I still don't like idea of translating to a different language than current locale).
 xtransLANG="$(grep '^transLANG' $CONFIG | cut -f2 -d= | cut -f1 -d' ')"
 if [ "$(echo -n "$ORIGLANG12" | grep "$xtransLANG")" == "" ]; then
  pupdialog --background '#FF8080' --msgbox "Sorry, but the transLANG variable in file ${CONFIG} is currently set to '${xtransLANG}'. MoManager requires that it be set to the current locale, '${ORIGLANG1}' or '${ORIGLANG12}'. Changing transLANG to '${ORIGLANG1}' in file ${CONFIG}" 0 0
  sed -i "s%^transLANG=.*%transLANG=${ORIGLANG1} #${ORIGLANG1} or ${ORIGLANG12}%" $CONFIG
 
  LANG=$ORIGLANG exec $thisSCRIPT refresh
 
 fi

 . $CONFIG    #130610
 
 [ "$transLANG" ] || transLANG=$ORIGLANG12
  
 mkdir -p $MOMADIR

 #add show_scripts parameter for combobox #170814
 if [[ ! "$(grep '^show_scripts=' $CONFIG)" ]]; then
   echo " 
# combobox for scripts that DO have a mo file
# note different content of help file
# change is effective AFTER Refresh
show_scripts='ALL'					 # default old way 
#show_scripts='ONE_per_TEXTDOMAIN'   # alternative way

"  >> $CONFIG
   . $CONFIG
 fi


 # add SORTby to $CONFIG #170618
 if [[ ! "$(grep '^SORTby=' $CONFIG)" ]]; then
  echo "
#SORTby='FILE'		# default # do NOT touch this line; toggle via GUI
SORTby='msgid'		# toggle  # do NOT touch this line; toggle via GUI
" >> $CONFIG
  exec $thisSCRIPT reenter
 fi

 # add AUTHORSPECS to $CONFIG
  x="
 Klick here to get focus and type in your name.
  
 This will be stored in $CONFIG

 and used in write.log of package: " 
 while [ "$AUTHORSPECS"  = "" ] ; do
	AUTHORSPECS=$(pupdialog --background yellow --inputbox "$x" 0 0 mrperson 2>&1) #170814
	[ "$AUTHORSPECS" ] || { clear ; x="$x, please: " ; continue ; }
	[ ${#AUTHORSPECS} -lt 4 ] && { clear ; AUTHORSPECS= ; x="$x, more than three letters please: " ; continue ; }
	echo "AUTHORSPECS=\"$AUTHORSPECS \"" >> $CONFIG
	. $CONFIG
 done

 # sort messages in po file 'by file (default)' or 'by msgid'
 [[ "$SORTby" = "msgid" ]] && SORTedby=FILE
 [[ "$SORTby" = "FILE" ]] &&  SORTedby=msgid

 # items in top-left drop-down list are one 'per script or 'per textdomain'
 [[ "$show_scripts" = "ALL" ]] && toggle_item_per="ONE_per_TEXTDOMAIN"
 [[ "$show_scripts" = "ONE_per_TEXTDOMAIN" ]] &&  toggle_item_per='one per script'

 kill_all_windows_titled 'At first please edit'

 combo_width

} # end config


tool_tip_SEARCH () {

 ttSEARCH="Find '${searchENTRY}' in all translation files, display name of translation file"
 [ "$CONTEXT_BEFORE" -eq 1 ] && ttSEARCH="$ttSEARCH and $CONTEXT_BEFORE line before"
 [ "$CONTEXT_BEFORE" -gt 1 ] && ttSEARCH="$ttSEARCH and $CONTEXT_BEFORE lines before"
 ttSEARCH="${ttSEARCH} line of found '${searchENTRY}'"
 [ "$CONTEXT_AFTER" -eq 1 ] && ttSEARCH="$ttSEARCH and $CONTEXT_AFTER line after"
 [ "$CONTEXT_AFTER" -gt 1 ] && ttSEARCH="$ttSEARCH and $CONTEXT_AFTER lines after"
 ttSEARCH="${ttSEARCH}. You can configure the number of these context lines in Preferences."

} #end tool_tip_SEARCH


sort_by_basename(){ #130602
 aFILE=$1; echo -n '' > ${aFILE}_; while read LINE; do
  echo "${LINE##*/}/${LINE}" >> ${aFILE}_ # ex:alsaconf/usr/sbin/alsaconf
 done < ${aFILE}
 LC_ALL=C sort ${aFILE}_ | cut -d '/' -f2- | tr '\n' ' ' > ${aFILE}
}


no_to_yes() {
	
	# update YES file and NO file using $APKGNAME #130505
	#ex: no_to_yes "$CACHE/YESMO_XML" "${ATEXTDOMAIN}.mo" "$CACHE/YESMO_XML" "$IN"

	#passed param $1 is NO file	ex: NOMO_XML
	#passed param $2 is identifier ex: xwin.mo
	#passed param $3 is YES file	ex: YESMO_XML
	#passed param $4 is optional: insert $4 after first '>'

	#called from create_mo: $1=$CACHE/NOMO_XML $3=$CACHE/YESMO_XML
	#called from edit_mo:   $1=$3=$CACHE/YESMO_XML
  
	#echo "move lines of $1 containing \"$2\" to begin of $3" #for debug only

	LINE_TO_MOVE="`grep -m 1 $2 $1`" #131212 bug fix #140307

	JUST_CREATED=${LINE_TO_MOVE//$4/} #remove $4 to avoid doubles

	[ "$4" = "$ISIN" ] && JUST_CREATED=${JUST_CREATED//$NOTIN/} && JUST_CREATED=${JUST_CREATED//$FUZZIN/} #140228 remove FUZZIN
	[ "$4" = "$NOTIN" ] && JUST_CREATED=${JUST_CREATED//$ISIN/} #140223 remove ISIN

	#build new YESMO_XML
	mv $3 ${3}_
	echo ${JUST_CREATED} | sed -e "s%<item>%<item>$4%g" > $3 # dto
	grep -v "${LINE_TO_MOVE}" ${3}_ >> $3 # others appended
 
	#build new NOMO_XML if was a create_*
	#[ "$1" != "$3" ] && { mv $1 ${1}_;  grep -v $2 ${1}_ > $1; }
	[ "EXIT" = "create_mo" ] && { mv $1 ${1}_;  grep -v $2 ${1}_ > $1; }

} # end of no_to_yes


update_cache () {
	
	case "$EXIT" in
	create_mo)
		[ "$METHOD" = "t12s" ] || MO='.mo' && MO=
		sed -i "s#(${ATEXTDOMAIN}#(${transLANG} ${ATEXTDOMAIN}${MO}#" ${CACHE}/NOMO_XML
		no_to_yes "${CACHE}/NOMO_XML" "${ATEXTDOMAIN}${MO}" "${CACHE}/YESMO_XML_ALL" "$NOTIN" #(not for ONE item per TEXTDOMAIN)
		# sorry, must delete item:
		sed -i "# (${transLANG} ${ATEXTDOMAIN}${MO} #d" ${CACHE}/NOMO_XML
		;;
	edit_mo)
		[ "$METHOD" = "t12s" ] || MO='.mo' && MO=
		sed -i "s#(${ATEXTDOMAIN}#(${transLANG} ${ATEXTDOMAIN}${MO}#" $CACHE/LATEST_edit_mo
		create_po_file_from "$CACHE/LATEST_edit_mo"
		[ "`grep fuzzy $WD/${ATEXTDOMAIN}.po`" ] && IN=$FUZZIN || IN=$ISIN #140309
		# move to top of combo (not for ONE item per TEXTDOMAIN)
		no_to_yes "$CACHE/YESMO_XML_ALL" " ${ATEXTDOMAIN} " "$CACHE/YESMO_XML_ALL" "$IN"
		;;
	create_bin)
		# update YESBIN_XML NOBIN_XML 
		no_to_yes $CACHE/NOBIN_XML "${ABIN}" $CACHE/YESBIN_XML
		sed -i "s#(${ANAME}#(${transLANG} ${AMO}#" $CACHE/YESBIN_XML
		echo -n "$((YESCNT + 1))" > $CACHE/YESCNT
		echo -n "$((NOCNT   - 1))" > $CACHE/NOCNT
		;;
	edit_bin)
		# move to top of combo  # not tested yet
		no_to_yes "$CACHE/YESBIN_XML" " ${ATEXTDOMAIN} " "$CACHE/YESBIN_XML"
		;;
	create_desk)
		no_to_yes $CACHE/NODESK_XML "${DESKFILE}" $CACHE/YESDESK_XML
		;;
	create_xml)
		no_to_yes $CACHE/NOXML_XML "${XMLFILE}" $CACHE/YESXML_XML
		;;
   esac
   
} #end update_cache



search_LC_MESSAGES () { #130604

 # pattern="$2"
 # "$TEXTDOMAINDIRVALUE/$transLANG/LC_MESSAGES"
 # cd "$1"
 #rm "$OUT_FILE"
 pattern="$1" 
 rm ${CACHE}/found_* 2>/dev/null
 export OUT_FILE="${CACHE}/found_$pattern"

 cd $defaultTEXTDOMAINDIRVALUE/${transLANG}/LC_MESSAGES
 num_files1=0
 #sleep 4;yaf-splash -close never -bg orange -text "Please wait, searching for '$pattern' in all mo files..." & #130610
 sleep 2 ; #time for main window to open
 if [ $POPUPFLAG -eq 1 ];then #150308
#  popup "name=mmpop2 background=#FFB030 level=top|Please wait, searching for \"${pattern}\" in all ${transLANG}/LC_MESSAGES/*mo files..."
  popup "terminate=20 name=mmpop2 background=#FFB030 level=top|Please wait, searching for \"${pattern}\" in all ${transLANG}/LC_MESSAGES/*mo files..."
 else
  CLOSE='-close never' ; [ "$isFATDOG" ] && CLOSE=
  yaf-splash ${CLOSE} -bg orange -text "Please wait, searching for \"$pattern\" in all ${transLANG}/LC_MESSAGES/*mo files..." & #131002 
  sPID=$! #130610
 fi
 for f in `ls *.mo`
 do
  #msgunfmt $f > dummy 
  msgunfmt $f 2>/dev/null > dummy || cp $f dummy # deprecated MU's "mo" files
  GREPped="`grep -n -E -B $CONTEXT_BEFORE -A $CONTEXT_AFTER --colour=always "$pattern" dummy`" #130610
  if [ "$GREPped" ]; then
   let num_files1=num_files1+1
   echo "${f#*/}" >> "$OUT_FILE"
   echo "$GREPped" >> "$OUT_FILE"
   echo '----------------------------' >> "$OUT_FILE"
  fi
 done
 search_result_TITLE1="Found '"$pattern"' in $num_files1  /usr/share/${HIGH_ON}locale/${transLANG}/LC_MESSAGES/*mo${HIGH_OFF} Files"
 echo " ${search_result_TITLE1}.
 ===============================================
 " >> "$OUT_FILE"
 #echo "[01;31m[KMomanager[m[K is the tool for creating and maintaining Language packs for ${HIGH_ON}Puppy, EasyOS and Fatdog ${HIGH_OFF}" >> "$OUT_FILE"

 #dto for t12s #131212 
 mkdir -p $TEXTDOMAINDIRVALUEs/${transLANG}
 cd $TEXTDOMAINDIRVALUEs/${transLANG}
 num_files2=0
 #for f in `ls *`
 for f in $(ls)
 do
  #msgunfmt $f > dummy 
  t12s_msgunfmt $f 2>/dev/null > dummy 
  GREPped="`grep -E -B $CONTEXT_BEFORE -A $CONTEXT_AFTER --colour=always "$pattern" dummy`" #130610
  if [ "$GREPped" ]; then
   let num_files2=num_files2+1
   echo "${f#*/}" >> "$OUT_FILE"
   echo "$GREPped" >> "$OUT_FILE"
   echo '----------------------------' >> "$OUT_FILE"
  fi
 done
 search_result_TITLE2="... and in $num_files2 /usr/share/${HIGH_ON}locales/${transLANG}/*${HIGH_OFF} Files"
 [ $num_files2 -gt 0 ] && echo " ${search_result_TITLE2}
 ===============================================
 " >> "$OUT_FILE"
 echo "[01;31m[KMomanager[m[K is the tool for creating and maintaining Language packs
 for ${HIGH_ON}Puppy, EasyOS and Fatdog ${HIGH_OFF}" >> "$OUT_FILE"

 search_result_TITLE="Found \"$pattern\"  $(($num_files1 + $num_files2)) times"

 rm dummy 2>/dev/null
 cd - >/dev/null
 if [ $POPUPFLAG -eq 1 ];then #150308
  popadd 'name=mmpop2 terminate=now|'
 else
  kill $sPID #130610
 fi
 
 #Xdialog --title "$search_result_TITLE" --textbox "$OUT_FILE" 22 77 #130610
 # Xdialog does not like the colours from grep --colour
 #[ "$SHOW_SEARCH_RESULT" -eq 1 ] && search_result || Xdialog --title "$search_result_TITLE" --textbox "$OUT_FILE" 22 77 #130610
 # I do not like browser for this thus we use console
 sync 
 LANG=$ORIGLANG urxvt -title "MoManager : $search_result_TITLE" -geometry ${CONS_WIDTH}x${CONS_HEIGHT} -hold -e cat "$OUT_FILE" &

} # end search_LC_MESSAGES


# strip_po  for GNU gettext po files
# make msgstr empty if identic to msgid
# make msgstr[0] empty if identic to msgid
# make msgstr[1] empty if identic to msgid_plural
#
# useful for translations to English (dialects)
# is also meant to be used by developers
# create pot file for your project and/or domain
# sort by msgid -> check messages
#                                
# L18L 2017, June 18 
strip_po () {

	[[ "$1" ]] || echo "usage: $0 file [ sort -s ]"
	
	local IN OUT WD MSGID MSGSTR n nn ntotal LINE FLAG
	local MSGIDPLUR MSGSTR0 MSGSTR1 MSGSTR2 MSGSTR3 x
	
	IN=$1
   	[[ -r "$IN" ]] || { echo "file $IN not found, aborting"; exit 1; }
   	[[ "$(file $IN |  grep -ho gettext)" ]] || { echo "$IN is not a gettext file, aborting"; exit 1; }

	#working directory and files
	WD=/tmp/momanager && mkdir -p $WD
	MSGID=$WD/MSGID
	MSGIDPLUR=$WD/MSGIDPLUR
	MSGSTR=$WD/MSGSTR
	MSGSTR0=$WD/MSGSTR0
	MSGSTR1=$WD/MSGSTR1
	MSGSTR2=$WD/MSGSTR2
	MSGSTR3=$WD/MSGSTR3

	################################################################
	#number of lines for input.po 
	ntotal=$(wc -l $IN | awk '{print $1}')

	# get line number of first blanc line
	nn=$(grep -E --line-number --max-count 1 '^$' $IN | sed 's/://')
	################################################################

	n=0; cat $IN | while read -r LINE; do

		# copy these lines
		[[ "$LINE" != "" ]] && echo $LINE
		until [[ $n -ge $nn ]]; do
			n=$(($n + 1))
			read -r LINE
			echo $LINE
		done

		# empty redundant msgstr
		until [[ $n -eq $ntotal ]]; do
			n=$(($n + 1))
			read -r LINE
			if [[ "${LINE:0:2}" = "#:" ]]; then
				FLAG=COMMENT
				echo $LINE
			fi
			if [[ "$LINE" = "" ]]; then	# OUTPUT
				echo -n 'msgid '
				cat  -v $MSGID
				if [[ "${#FLAG}" = "1" ]]; then # plural(s) from ngettext
					echo -n 'msgid_plural '
					cat  -v $MSGIDPLUR
					echo 'msgstr[0] ""'
					[[ "$(< $MSGSTR0)" = "$(< $MSGID)" ]] || cat -v $MSGSTR0
                     for x in  1 2 3; do # languages may have more than 1 plural
						if [[ $FLAG -ge $x ]]; then
							echo "msgstr[$x] \"\""
							[[ "$(< $MSGSTR$x)" = "$(< $MSGIDPLUR)" ]] || cat  -v $MSGSTR$x
						else
							break
						fi	
                    done                             
				
				else
					echo 'msgstr ""'
					[[ "$(< $MSGSTR)" = "$(< $MSGID)" ]] || cat -v $MSGSTR
				fi
				> $MSGID
				> $MSGIDPLUR
				> $MSGSTR
				> $MSGSTR0 #MSGSTR1 MSGSTR2 MSGSTR3
				echo "$LINE"
				FLAG=
			fi	
			case "${LINE}" in
			 msgstr\[*)	FLAG="${LINE:7:1}"
						echo "${LINE:10}" > $MSGSTR$FLAG
						;;
				msgst*)	FLAG=MSGSTR; echo "${LINE:7}" > $MSGSTR ;;
		   msgid_plur*)	FLAG=MSGIDPLUR ; echo "${LINE:13}" > $MSGIDPLUR ;;
			    msgid*)	FLAG=MSGID ; echo "${LINE:6}" > $MSGID ;;
		           \"*)	case $FLAG in
								[0-9])	echo "$LINE" >> $MSGIDPLUR  ;;
							  MSGIDPL)  echo "$LINE" >> $MSGIDPLUR  ;;
								MSGID)  echo "$LINE" >> $MSGID  	;;
						   MSGSTRPLUR)	echo "$LINE" >> $MSGSTRPLUR ;;
							   MSGSTR)	echo "$LINE" >> $MSGSTR		;;
						esac
						;;
			esac
		done
		break
	done
	rm $MSGID $MSGSTR $MSGIDPLUR $MSGSTR* 2>/dev/null

} # tested by: strip_po get_app.po > s_get_app.po  


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"
 if [ $POPUPFLAG -eq 1 ];then #150308
  case $BACKCOL in #hack
   yellow)    BACKCOL='#FFFF00' ;;
   LightPink) BACKCOL='#FF30FF' ;;
   orange)    BACKCOL='#FFB030' ;;
   *)         BACKCOL='#FFFF66' ;;
  esac
  echo "#!/bin/sh
  sleep 1 #not needed.
  popup 'name=mmpop3 level=top background=${BACKCOL} placement=top-middle terminate=${POPTIME}|${1}'" > $WD/yafmsg9${POPTIME}
 else
  echo "#!/bin/sh
  sleep 3
  yaf-splash -bg ${BACKCOL} -placement top -timeout ${POPTIME} -text \"${1}\"
  " > $WD/yafmsg9${POPTIME}
 fi
 chmod 755 $WD/yafmsg9${POPTIME}
 $WD/yafmsg9${POPTIME} & #msg has delay so will appear on top of text editor window.
}


get_prop () { # get properties
	
 # input: SCRIPT
 # eval $(eval get_prop <SCRIPT>) is command to get output
 # output: METHOD ATEXTDOMAINDIR ATEXTDOMAIN PATTERN AMOSPEC NOFUZZY 
 
 local S # SCRIPT
 local M # METHOD
 local T # ATEXTDOMAIN
 local D # ATEXTDOMAINDIR
 local P # PATTERN
 local A # AMOSPEC
 local N # NOFUZZY 
 S=$1
 
 [ "$S" ] || die "Parameter \"SCRIPT\" needed"

 # METHOD
 # note, gettext method does NOT need explicit 'gettext', see ex: /etc/grub.d/20_ppc_terminfo
 # thus grep gettext is not useful
 case ${S##*.} in
  md) M='mdview' ;;
   *) [ "`grep -m 1 '${_M_'   $S`" ] && M='t12s' || M='gettext' ;;
 esac

 #TEXTDOMAIN
 case "$M" in
  gettext|t12s) T="`grep -m 1 '^export TEXTDOMAIN=' $S`"; T=${T#*=} ;;
  mdview)       T="`grep -m 1 '^%%textdomain ' $S `"; T=${T#* }
                [ `which mdview` ] || die "mdview not found"
                [[ `mdview --help |  grep 'po file'` ]] || die "wrong version  of mdview"
                ;;
 esac  
 T="${T%% *}" ; [ "$T" ] || die "$S : $T : no TEXTDOMAIN found"


 #TEXTDOMAINDIR
 case "$M" in
   gettext) D="`grep -m 1 '^export TEXTDOMAINDIR=' $S `"; D=${D#*=}
			[ -d $(dirname $S)/locale ] && D=$(dirname $S)/locale || D=${defaultTEXTDOMAINDIRVALUE}
			;;
	  t12s) D=${defaultTEXTDOMAINDIRVALUE}s	
			;;
	mdview)	D="`grep -m 1 '^%%textdomaindir ' $S `"; 	  D=${D#* } # always empty
			[ -d $(dirname $S)/locale ] && D=$(dirname $S)/locale || D=${defaultTEXTDOMAINDIRVALUE}
            [ `which mdview` ] || die "mdview not found"
            [[ `mdview --help |  grep 'po file'` ]] || die "wrong version  of mdview"
            ;;
 esac

# #catch case of "TEXTDOMAINDIR=${...}/locale" where ${...} is empty: UExtract
# [ $(echo $D | tr '/' ' '| wc -w) -lt 3 ] && D=$(dirname $S)/$D

 #catch case of "TEXTDOMAINDIR=${datarootdir}/locale" where ${...} is empty (grub):
# [ $(echo $D | tr '/' ' '| wc -w) -lt 3 ] && D=${defaultTEXTDOMAINDIRVALUE}

 #or  D=$(dirname $S)/$D

 #
 case $M in
  gettext) P="^export TEXTDOMAIN=${T}" 
           A="$D/${transLANG}/LC_MESSAGES/${T}.mo"
           N= 
           ;;
   mdview) P="^%%textdomain ${T}" 
           A="$D/${transLANG}/LC_MESSAGES/${T}.mo"
           N= 
           ;;
     t12s) P="^export TEXTDOMAIN=${T}" 
           A="${defaultTEXTDOMAINDIRVALUE}s/${transLANG}/${T}"	#ex:  ...locales/ll/$T
           N='--no-fuzzy-matching'
           ;; 
 esac

 echo "ATEXTDOMAIN=\"$T\" TEXTDOMAINDIRVALUE=\"$D\" METHOD=\"$M\" tdPTN=\"$P\" AMOSPEC=\"$A\" NOFUZZY=\"$N\""
 
}
export -f get_prop


t12s_xgettext () { # has been an extern script befor
	               # assign ID automatically, i.e. edit just ${_M_:-message}
	local x TEXTDOMAINVALUE A B ID CONTENT PATTERN id LAST_ID SCRIPT MSG TMP	
	TMP=_TEXTDOMAINVALUE_
	> $TMP
	> ${TMP}_unsorted
	> lastID
	#create translation file with ID (ex:_M_5) and without ID (ex:_M_)
	for x in $@
	do 
		while read  A || [ "$A" ]
		do
			case "$A" in
			*{_M_*) 	B=_M${A#*_M};B=${B%%\}*}\'
						echo ${B//:-/=\'} >> ${TMP}_unsorted
						#ex:_M_1='hello world'
						;;
			esac
		done < $x
	done 
	grep -v '_M_=' ${TMP}_unsorted | sort -u > $TMP		#items with	   ID
	grep    '_M_=' ${TMP}_unsorted | sort -u > ${TMP}._ #items without ID
	rm ${TMP}_unsorted
	# items with ID: insert if MSG already used
	cat ${TMP} | while read LINE || [ "$LINE" ]
	do
		MSG=${LINE#*=}
		MSG=$(echo -n $MSG | cut -d"'" -f2)
		echo $MSG >> ${WD}/MSG

		ID=$(grep -E "${MSG//\$/\\$}" $TMP | cut -d'=' -f1)
		ID=${ID//_M_/}
		ID=$(echo -n $ID) #ex:4
		#insert ID in each of the scripts using TEXTDOMAIN
		for x in $@
		do
			#[ $ID -gt 0 ] && sed -i "s#_M_:-${MSG}#_M_${ID}:-${MSG}#" $x
			[ "$ID" ] && sed -i "s#_M_:-${MSG}#_M_${ID}:-${MSG}#" $x
		done
		#fill pot
		echo "#: ${LINE%=*}"    #ex:#: _M_1
		echo 'msgid "'${MSG}'"' #ex:msgid "hello world"
		echo "msgstr \"\""      #ex:msgstr "" 
		echo ""
	done
	# get highest ID from sorted list ${TMP}
	#[[ -s ${TMP} ]] && lastID=$(tail -n 1 $TMP | cut -d'=' -f1 | cut -d'_' -f3) 
    #181207 fix
	[[ -s ${TMP} ]] && lastID=$(cut -d_ -f3 $TMP | cut -d= -f1 | sort -rn | head -n1) \
	                || lastID=0
	echo -n $lastID > ${WD}/lastID
	# items without ID: assign new ID
	cat ${TMP}._ | while read LINE || [ "$LINE" ]
	do
		MSG=${LINE#*=}
		MSG=$(echo -n $MSG | cut -d"'" -f2)
		echo $MSG >> ${WD}/MSG
		read lastID < ${WD}/lastID
		ID=$(($lastID + 1))
		echo $ID > ${WD}/lastID
		#insert ID in each of the scripts using TEXTDOMAIN
		for x in $@
		do
			[ $ID -gt 0 ] && sed -i "s#_M_:-${MSG}#_M_${ID}:-${MSG}#" $x
		done
		#fill pot
		echo "#: _M_${ID}" 		#ex:#: _M_99 (ID fix 181207)
		echo 'msgid "'${MSG}'"' #ex:msgid "hello world"
		echo "msgstr \"\""      #ex:msgstr "" 
		echo ""
	done
#	rm ${TMP} ${TMP}._
}
export -f t12s_xgettext


t12s_msgunfmt () { # has been an extern script before; equivalent of GNU msgunfmt
	
 [ -f "$1" ]  || die "$0: $1 is not a file"
 
 local LINE t12s_ID MSGID MSGSTR

# echo "\"#Translate/Check ${ATEXTDOMAIN}.po created by $0\"
#\"Language: ${transLANG}\n\"
#\"Content-Type: text/plain; charset=UTF-8\n\"
#"

 echo "\"Language: ${transLANG}\n\""


#ex  input:#hello world
#          _M_1="Hallo Welt"

#ex output (po):#: _M_1
#               msgid "hello world"
#               msgstr "Hallo Welt"

 while read LINE
 do
  case $LINE in
   \#*)
    [ "${LINE:0:2}" = "#:" ] && continue
    MSGID=${LINE:1}            # 1st 2 char removed which was '#: '
    MSGID=${MSGID//\"/\\\"}    # quotes escaped

    read LINE
    MSGSTR=${LINE#*\"}; MSGSTR=${MSGSTR%\"*} # first and last quote removed
    MSGSTR=${MSGSTR//\"/\\\"}                # quotes escaped
      
    t12s_ID=${LINE%=*}
    [ "$t12s_ID" ] || continue
 
    echo "#: ${t12s_ID}"
    echo 'msgid "'${MSGID}'"'
    echo 'msgstr "'${MSGSTR}'"'
    echo
    ;;
  esac
 done < $1
 
}
export -f t12s_msgunfmt

t12s_msgfmt () { # has been an extern script before; equivalent of GNU msgfmt

 [[ -f "$1" ]]  || die "$0: $1 is not a file"
################################# [[ "$1##*." = "po" ]] || die "$0: $1 is not a .po file"
 
 local LINE t12s_ID A MSGID MSGSTR
 
# echo "# created `date`
# from only temporarily existing $1
# created by $0
# from $(cat xEXTRASCRIPTS | sed 's/^/#/')
#"

### TODO:
##  skip fuzzy
#   "$(grep '#, fuzzy' $TMP 2>/dev/null)" 



#ex input (po):#: _M_1
#              msgid "hello world"  !!! ONE LINE ONLY !!!!!!!!!!!!!! important
#              msgstr "Hallo Welt"

#ex output:#hello world
#         _M_1="Hallo Welt"

 while read LINE
 do
  case "$LINE" in
   \#:\ _M_*)
    t12s_ID="_${LINE#*_}" # "_ and all after first underscore
    
    read LINE    		                    # ex:msgid "hello world"
    [[ "${LINE:0:1}" = "#" ]] && read LINE
    A="${LINE#*\"}"  						# all after first quote, ex:hello world"
    MSGID="${A%\"*}" 						# all before last quote, ex:hello world
        
    MSGSTR= # translator might have used SEVERAL lines
    while : ; do
     read LINE
     [ "$LINE" ] || break
     A="${LINE#*\"}"; A="${A%\"*}" # first and last quote removed
     A="${A//\"/\\\"}"             # quotes escaped
     MSGSTR="${MSGSTR}${A}"
    done 
         
    [[ "${MSGSTR}" ]] || continue			# not yet trabnslated
    [[ "${MSGSTR:0:1}" = "#" ]] && continue # comment
    
    echo "#${MSGID}"             	   		# ex:#foo bar
    echo "${t12s_ID}=\"${MSGSTR}\"" 		# ex:_M_4="translation of foo bar"
    echo ""
    ;; 
  esac
 done < $1
 echo
}
export -f t12s_msgfmt


# ex: extract_blocks_containing '^# _M_' ${ATEXTDOMAIN}.po
# ex: extract_blocks_containing '^#: '   ${ATEXTDOMAIN}.po
extract_blocks_containing () {

 local PATTERN FILE B LINE

 PATTERN=$1
 FILE=$2 ; [ "$FILE" ] || die "missing input file"
 B=/tmp/${0##*/}BLOCK$$
 echo "" >> $FILE # empty LINE is delimiter of BLOCK

 while read LINE; do
  [[ "$LINE" ]] || { [ "$(grep -s "$PATTERN" $B)" ] && cat $B; rm $B; }
  echo "$LINE" >> $B # append LINE to BLOCK
 done < $FILE

 rm $B
}
export -f extract_blocks_containing

create_actual_pot_file_header () {
	
 # for simple TEXTDOMAIN and for new cumulatedTEXTDOMAIN
 [ "${ANAME}" ] || ANAME="${ASCRIPT##*\/}"
 [ "${ATEXTDOMAIN}" ] || ATEXTDOMAIN="${TD_NEW}"

 echo -n "create_actual_file ${ATEXTDOMAIN}.pot METHOD=$METHOD"
 # create header (empty pot) and use always -j parameter: join existing  #150404
 echo " " | xgettext -o ${ATEXTDOMAIN}.pot -L shell --no-wrap --force-po -

# ANAME="${ASCRIPT##*\/}"
# aPTN="s%Project-Id-Version: PACKAGE VERSION%Project-Id-Version: ${ANAME} VERSION%"
 aPTN="s%Project-Id-Version: PACKAGE VERSION%Project-Id-Version: ${ATEXTDOMAIN} 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%"

 busybox sed -i -e "$aPTN" -e "$bPTN" -e "$cPTN" -e "$dPTN" ${ATEXTDOMAIN}.pot
 
}
export -f create_actual_pot_file_header




create_actual_pot_file () {
 
 create_actual_pot_file_header   
   
 #120731 multiple scripts may have the same TEXTDOMAIN...
 #151230 may use different METHOD (gettext and mdview) now

 EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "^export TEXTDOMAIN=${ATEXTDOMAIN}" INPUTFILE | sed -e 's%SPACECHAR% %g')" 
 # append .md scripts
 EXTRASCRIPTS="$EXTRASCRIPTS $(echo "$GETTEXTSCRIPTS" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "%%textdomain ${ATEXTDOMAIN}" INPUTFILE | sed -e 's%SPACECHAR% %g')" 

 echo -n "" > ./xEXTRASCRIPTS
 echo "$EXTRASCRIPTS" | while read ONEEXTRA
 do
  [ "$ONEEXTRA" ] || continue # skip empty line
  [ -f "$ONEEXTRA" ] || continue #precaution.
  echo "${ONEEXTRA}" >> ./xEXTRASCRIPTS # 150313
  [[ -f ${ONEEXTRA}.xml ]] && echo ${ONEEXTRA}.xml >> ./xEXTRASCRIPTS #150404 (GLADE files)
 done
 
 # fill pot file
 xgettext -j -o ${ATEXTDOMAIN}.pot -ci18n --from-code=UTF-8 -L Shell --no-wrap `grep -v '.sh.xml' ./xEXTRASCRIPTS` 2>/dev/null 

 has_GLADE_FILE="`grep '.sh.xml$' ./xEXTRASCRIPTS`"
 [ "$has_GLADE_FILE" ] && xgettext -j -o ${ATEXTDOMAIN}.pot -c --from-code=UTF-8 --keyword=translatable -L Glade --no-wrap $has_GLADE_FILE >/dev/null

 has_MDVIEW_FILE="`grep '.md'    ./xEXTRASCRIPTS`"
 if [[ "$has_MDVIEW_FILE" ]]; then
  [ "`mdview --help | grep path 2>/dev/null`" ] && OBJ="\${aFILE}" || OBJ="\${aFILE%/*} \${aFILE##*/}" #151108 new mdview feature
  for aFILE in $(cat ./xEXTRASCRIPTS)
  do
   [ "${aFILE##*.}" = "md" ] || continue
   eval mdview --po $OBJ >> ${ATEXTDOMAIN}.pot
  done
  [ "$METHOD" = "mdview" ] || echo -n " mdview "  
 fi

 has_t12s_FILE="`for f in $(cat ./xEXTRASCRIPTS); do grep -m 1 '_M_' $f; done`"
 if [[ "$has_t12s_FILE"  ]]; then
  t12s_xgettext $(cat ./xEXTRASCRIPTS) >> ${ATEXTDOMAIN}.pot
  [ "$METHOD" = "t12s" ] || echo -n " t12s "
  sync 
 fi 
 
 if [[ "$has_MDVIEW_FILE" || "$has_t12s_FILE" ]]; then
  cp ${ATEXTDOMAIN}.pot ${ATEXTDOMAIN}_.pot
  msguniq ${ATEXTDOMAIN}_.pot > ${ATEXTDOMAIN}.pot
  rm ${ATEXTDOMAIN}_.pot
 fi 
 echo

} #/create_actual_pot_file


#create_po_file_from `cat $CACHE/YESMO_XML`
#create_po_file_from "LATEST_edit_mo" 
# code from edit_mo but optimized for speed
# without appending .sh because -L Shell parameter is being used
create_po_file_from () 
{ 
 SOURCE_LIST=$1
 [ "$SOURCE_LIST" ] || die "create_po_file_from cannot continue without SOURCE_LIST file parameter"
 [ -f "$SOURCE_LIST" ] || die "file $SOURCE_LIST not found"
 echo "create_po_file_from SOURCE_LIST=$SOURCE_LIST"
 cd $WD 
 while read YESMO_COMBO; do
  [ "$YESMO_COMBO" ] || continue # no blanc lines allowed
  YESMO_COMBO="${YESMO_COMBO#*${SEPARATOR}}" # cut -d "$SEPARATOR" -f2- #130609
  YESMO_COMBO="${YESMO_COMBO%%<*}" # cut -d "<" -f1 #140228
  #ex: YESMO_COMBO='/usr/sbin/mousecheck (de mousecheck.mo)'
  [ "`echo "$YESMO_COMBO" | grep "$NOTIN" >/dev/null`" ] && continue #check only ISIN
  #ASCRIPT="`echo -n "$YESMO_COMBO" | cut -f 1 -d '(' | rev | cut -f 2-9 -d ' ' | rev`"
  ASCRIPT="${YESMO_COMBO%%(*}"; ASCRIPT="${ASCRIPT/ /}" #faster 

  ANAME="${ASCRIPT##*\/}" #ANAME="`basename "$ASCRIPT"`"

  ATRANSLANG="${YESMO_COMBO#*(}"; ATRANSLANG="${ATRANSLANG%% *}" #faster than #ATRANSLANG="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`" #ex: de
  #echo "ATRANSLANG=$ATRANSLANG"

  AMO="${YESMO_COMBO#*(}"; AMO="${AMO#* }"; AMO="${AMO% *}" #faster than   #AMO="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: mousecheck.mo
  #echo "AMO=$AMO"
  APKGNAME="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 3 -d ' '`" #ex: bluefish  ex: WOOF
  
  eval $(eval get_prop $ASCRIPT)

  [ -f $WD/${ATEXTDOMAIN}.pot ] && continue # 20151001
  
 #  case "$METHOD" in
 #  gettext)   msgunfmt  "$AMOSPEC" > $WD/${ATEXTDOMAIN}1.po ;;
 #  mdview)    msgunfmt  "$AMOSPEC" > $WD/${ATEXTDOMAIN}1.po ;; 
 #  t12s) t12s_msgunfmt "$AMOSPEC" > $WD/${ATEXTDOMAIN}1.po ;;
 #  esac  
 
  # as same TEXTDOMAIN can be used by t12s AND gettext/mdview
  # $AMOSPEC can be foo or foo.mo
  # try $AMOSPEC and ${AMOSPEC//.mo/} OR $AMOSPEC and ${AMOSPEC}.mo
  HYBR=

  if [ -f ${AMOSPEC} ]; then

   if [[ "$METHOD" = "t12s" ]]; then

    #create empty $WD/${ATEXTDOMAIN}2.po
    echo " " | xgettext -o $WD/${ATEXTDOMAIN}2.po -L shell --force-po -
    #sed -i -e 's/#, fuzzy/d' $WD/${ATEXTDOMAIN}2.po
    sed -i -n '/#, fuzzy/!p' $WD/${ATEXTDOMAIN}2.po

# aPTN="s%Project-Id-Version: PACKAGE VERSION%Project-Id-Version: ${ANAME} VERSION%"
 aPTN="s%Project-Id-Version: PACKAGE VERSION%Project-Id-Version: ${ATEXTDOMAIN} 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%"

    busybox sed -i -e "$aPTN" -e "$bPTN" -e "$cPTN" -e "$dPTN" $WD/${ATEXTDOMAIN}2.po

    t12s_msgunfmt "${AMOSPEC}" >> $WD/${ATEXTDOMAIN}2.po
 
    cp -f "${AMOSPEC}" $WD/${ATEXTDOMAIN}2.moOLD

    if [ -f ${AMOSPEC}.mo ]; then
     msgunfmt --no-wrap "${AMOSPEC}.mo" > $WD/${ATEXTDOMAIN}1.po
     cp -f "${AMOSPEC}.mo" $WD/${ATEXTDOMAIN}1.moOLD
     HYBR='HYBR'
    fi

   else 
    
    msgunfmt --no-wrap "$AMOSPEC" -o - > $WD/${ATEXTDOMAIN}1.po
    cp -f "$AMOSPEC" $WD/${ATEXTDOMAIN}1.moOLD
    if [ -f ${AMOSPEC//.mo/} ]; then
     t12s_msgunfmt  "${AMOSPEC//.mo/}" > $WD/${ATEXTDOMAIN}2.po
     cp -f "${AMOSPEC//.mo/}" $WD/${ATEXTDOMAIN}2.moOLD
     HYBR='HYBR'
    fi
   fi
  else    
   die "$0 #: missing file ${AMOSPEC}"   

  fi
    
  [[ "$HYBR" ]] && echo "$ATEXTDOMAIN " >> $CACHE/HYBR
  
  case $ATEXTDOMAIN in
   alsaconf)
    #rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
    echo using static /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot
    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
     echo using static /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot
     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')"
     echo -n "" > ./xEXTRASCRIPTS
     echo "$EXTRASCRIPTS" |  while read ONEEXTRA
     do
      [ "$ONEEXTRA" ] || continue
      [ -f "$ONEEXTRA" ] || continue #precaution.
      echo "${ONEEXTRA}" >> ./xEXTRASCRIPTS # 150313
      [ -f ${ONEEXTRA}.xml ] && echo ${ONEEXTRA}.xml >> ./xEXTRASCRIPTS #150404 (GLADE files)
     done
     [ -f ${ATEXTDOMAIN}.pot ] || create_actual_pot_file # once only
     [ -f ${ATEXTDOMAIN}.pot ] || die "Could not create ${ATEXTDOMAIN}.pot"
     [ -z ${ATEXTDOMAIN}.pot ] && die "Could create empty ${ATEXTDOMAIN}.pot only."
    fi
   ;;
  esac 

  #this syncs textdomain1.po and/or textdomain2.po and textdomain.pot, merges to textdomain.po ...

  rm -f ${ATEXTDOMAIN}.po 2>/dev/null
  if [ -f ${ATEXTDOMAIN}1.po ]; then
   msgmerge -q $NOFUZZY --no-wrap ${ATEXTDOMAIN}1.po ${ATEXTDOMAIN}.pot -o - > ${ATEXTDOMAIN}.po 
   if [ -f ${ATEXTDOMAIN}2.po ]; then
    msgmerge -q $NOFUZZY --no-wrap ${ATEXTDOMAIN}2.po ${ATEXTDOMAIN}.po -o - > ${ATEXTDOMAIN}3.po 
    mv ${ATEXTDOMAIN}3.po ${ATEXTDOMAIN}.po
   fi  
  else  
   msgmerge -q $NOFUZZY --no-wrap ${ATEXTDOMAIN}2.po ${ATEXTDOMAIN}.pot -o - > ${ATEXTDOMAIN}.po 
  fi 

  if [ "$isFATDOG" ]; then
   : # fatdog's nls has a version, e.g. 702;
     # thus translations which are no more in use by the actual version are not needed to be kept.
   [ "$HYBR" ] || sed -i 's/^#~ //' ${ATEXTDOMAIN}.po # just for me debugging
  else  
   #141008 remove comment sign, ex: change #~ msgid "bla" to msgid "bla"
   sed -i 's/^#~ //' ${ATEXTDOMAIN}.po #150309
  fi
  
  #modify PACKAGE again # ????
  busybox sed -i -e "s% PACKAGE% ${ANAME}%" ${ATEXTDOMAIN}.po  
  
 done < $SOURCE_LIST
 
} # /create_po_file_from


edit_until_error_free_or_break () {
	
 #170618 Sort by msgid or FILE
 [[ "$SORTby" = "msgid" ]] && msguniq -s -o $WD/sorted_${ATEXTDOMAIN}.po ${ATEXTDOMAIN}.po ||
 msguniq -F -o $WD/sorted_${ATEXTDOMAIN}.po ${ATEXTDOMAIN}.po

# [[ "$SORTby" = "msgid" ]] && SORT_OPTION='-s' || SORT_OPTION='-F'
# msguniq "$SORT_OPTION" $WD/sorted_${ATEXTDOMAIN}.po ${ATEXTDOMAIN}.po
 
 # replace PACKAGE by ${ANAME}
 busybox sed -e "s% PACKAGE% ${ANAME}%"  $WD/sorted_${ATEXTDOMAIN}.po  >     ${ATEXTDOMAIN}.po  && rm $WD/sorted_${ATEXTDOMAIN}.po

 #130502 L18L/BK: stay in a loop if there is an error converting .po to .mo...
 cp -f $WD/${ATEXTDOMAIN}.po $WD/${ATEXTDOMAIN}.poBACKUP1

 while true ; do

  if [ "$POEDITOR" ];then
   LANG=${ORIGLANG} ${POEDITOR} $WD/${ATEXTDOMAIN}.po
  else
   killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
   sleep 0.5
   LANG=${ORIGLANG} defaulttexteditor $WD/${ATEXTDOMAIN}.po
  fi

  if [ ! diff -q $WD/${ATEXTDOMAIN}.poBACKUP1 $WD/${ATEXTDOMAIN}.po  >/dev/null 2>&1 ] ; then #130503
   ABORTFLG=8
   break
  fi
  
  #LANG=${ORIGLANG} msgfmt --output-file=- $WD/${ATEXTDOMAIN}.po >/dev/null 2> $WD/po-2-mo.err 
  case $METHOD in
   gettext|mdview) LANG=${ORIGLANG}
                   msgfmt --output-file=- $WD/${ATEXTDOMAIN}.po >/dev/null 2> $WD/po-2-mo.err ;;
             t12s) t12s_msgfmt $WD/${ATEXTDOMAIN}.po > /dev/null 2>$WD/po-2-mo.err ;;
  esac 
  [ ! -s $WD/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 $WD/po-2-mo.err`

NOTE: The above error message is logged to $WD/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 $WD/${ATEXTDOMAIN}.poBACKUP1 $WD/${ATEXTDOMAIN}.po ; continue ;; #Revert
   *)  ABORTFLG=9 ; break ;; #1=Abort
  esac
 done
  
 [ $ROPID -ne 0 ] && kill $ROPID

} #/edit_until_error_free_or_break


create_a_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}/ 2>/dev/null

  #200112
  DISTRO_PUPPYDATE="$(grep '^DISTRO_PUPPYDATE' /etc/DISTRO_SPECS | cut -f 2 -d "'")"
  TEXT="${GENLANG} language-pack for ${PUPPY}, built from Woof on or later than ${DISTRO_PUPPYDATE}" #140104
  echo "${LANGPACK}_${GENLANG}-${ADATE}|${LANGPACK}_${GENLANG}|${ADATE}||Setup|1104K||${LANGPACK}_${GENLANG}-${ADATE}.pet||$TEXT||||" > /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 $WD/translations4langpack |
  while read ALINE
  do

   #[ "$isFATDOG" -a "`grep ${ALINE} /root/.packages/langpack_de-*`" ] && continue #131206 Fatdog: take just those files that are not in basic langpack
   #[ "$isFATDOG" -a "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ] && continue #131206 Fatdog: take just those files that are not in basic langpack #140101
   #if [ "$isFATDOG" -o "$isQUIRKY" ]; then # take just those files that are not in basic langpack #140104

###   if [ "$isQUIRKY" ]; then # 150313 for quirky only
###    [ "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ] && continue
###   fi
###190118
      
   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 #130806 
  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...

#-----------------------------------------------------
#if  [ -z "$isFATDOG" ]; then   #131206 but not for Fatdog
if  [ -z "$isFATDOG" -a -z "$isEASYOS" ]; then #140104 but not for Fatdog and not for Quirky
#-----------------------------------------------------
  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 $TEXTDOMAINDIRVALUEs/${ORIGLANG1} ];then
    mkdir -p /root/${LANGPACK}_${GENLANG}-${ADATE}$TEXTDOMAINDIRVALUEs/${ORIGLANG1}
    cp -a -f $TEXTDOMAINDIRVALUEs/${ORIGLANG1}/* /root/${LANGPACK}_${GENLANG}-${ADATE}$TEXTDOMAINDIRVALUEs/${ORIGLANG1}/
   fi
   if [ -d $TEXTDOMAINDIRVALUEs/${ORIGLANG12} ];then
    mkdir -p /root/${LANGPACK}_${GENLANG}-${ADATE}$TEXTDOMAINDIRVALUEs/${ORIGLANG12}
    cp -a -f $TEXTDOMAINDIRVALUEs/${ORIGLANG12}/* /root/${LANGPACK}_${GENLANG}-${ADATE}$TEXTDOMAINDIRVALUEs/${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

#-----------------------------------------------------
fi    #131206 but not for Fatdog
#-----------------------------------------------------  
  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 \

} # end of create_a_pet



edit_create_mo ()  { 					# eliminated duplication of code
#-----------------------------------------------------------------------
 local 

  case "$EXIT" in 
  edit_mo)
    
    if [ ! -s "$CACHE/YESMO_XML" ]; then
		export LANG=$ORIGLANG
		exec $thisSCRIPT reenter 
    fi
    
    grep -m 1 "$YESMO_COMBO" "$CACHE/YESMO_XML" > $CACHE/LATEST_edit_mo
 
    ### delete .pot file if you have made any relevant changes to one of its scripts
    ## or remove ## to get always fresh pot file (slower)
    ## POT_FILE="`cat $CACHE/LATEST_edit_mo | cut -d '(' -f 2 | cut -d ' ' -f2 | sed -e 's/mo$/pot/'`"
    ## rm $WD/${POT_FILE} || die "could not delete pot file $WD/${POT_FILE}"
    ##
 
    create_po_file_from $CACHE/LATEST_edit_mo
    BINMSG="The .mo file has been converted to an editable .po file. Edit, then Save, then Quit text editor..."
    ;;
    
  create_mo)
    
    #if [ ! -s "$CACHE/NOMO_XML" ]; then
#		export LANG=$ORIGLANG
#		exec $thisSCRIPT reenter 
#    fi

    # special case transLANG=en pseudo translation "X English" #200606
    # create all gettext po files
    case "$transLANG" in
    en) 
      while read ASCRIPT ATEXTDOMAN APKGNAME  
      do
        [ "$ASCRIPT" ]     || continue # skip totally empty line
        ASCRIPT=${ASCRIPT#*${SEPARATOR}}
        APKGNAME=${APKGNAME%)*}        
        eval $(eval get_prop $ASCRIPT) #  get METHOD, TEXTDOMAINDIR,...
        case "$METHOD" in
        gettext)
          create_actual_pot_file
	      msginit --no-translator --no-wrap --locale=${transLANG} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot

          sed -e "s%msgstr \"%msgstr \"${Xenglish}%" ${ATEXTDOMAIN}.po > s_${ATEXTDOMAIN}.po
          sed -e "s/${Xenglish}\\n/\\n${Xenglish}/" s_${ATEXTDOMAIN}.po > ${ATEXTDOMAIN}.po
          sync
          
          #create .mo
          LANG=${ORIGLANG} rxvt -e msgfmt --output-file=$WD/${ATEXTDOMAIN}.mo $WD/${ATEXTDOMAIN}.po 
          ;;
        esac
        update_cache
      done < ${CACHE}/NOMO_XML
	  > ${CACHE}/NOMO_XML
	  #sort uniq TEXTDOMAIN
	  sort -u ${CACHE}/YESMO_XML_ALL > ${CACHE}/YESMO_XML_ALL_ &&     mv ${CACHE}/YESMO_XML_ALL_  ${CACHE}/YESMO_XML_ALL
      export LANG=$ORIGLANG  
      exec $thisSCRIPT reenter
      # end special case transLANG=en pseudo translation "X English" #200606
      ;;
    esac
    
    grep -m 1 "$NOMO_COMBO" "$CACHE/NOMO_XML" > $CACHE/LATEST_create_mo

    # create_po_file_from $CACHE/LATEST_create_mo
 
    NOMO_COMBO="${NOMO_COMBO#*${SEPARATOR}}" # cut -d "$SEPARATOR" -f2- #130609
    #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 '_'`"
    [ "$ASCRIPT" ] || LANG=$ORIGLANG exec $thisSCRIPT restart	 # --empty--

    eval $(eval get_prop $ASCRIPT) #  get METHOD, TEXTDOMAINDIR,...
      
    create_actual_pot_file
	msginit --no-translator --no-wrap --locale=${transLANG} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot

    # msginit --locale=en creates po file with msgstr filled by msgid. not good
    # need other code for locale=en and for locale=en_*
    # created a function to strip identic msgstr: strip_po  #170618
    if [ "${transLANG}" = "en" ]; then #200317
     sed -e "s%msgstr \"%msgstr \"${Xenglish}%" ${ATEXTDOMAIN}.po > s_${ATEXTDOMAIN}.po
    #if [ "${transLANG%_*}" = "en" ]; then
    elif [ "${transLANG%_*}" = "en" ]; then
     strip_po ${ATEXTDOMAIN}.po > s_${ATEXTDOMAIN}.po
     #sync && mv s_${ATEXTDOMAIN}.po ${ATEXTDOMAIN}.po
	fi
    sync && mv s_${ATEXTDOMAIN}.po ${ATEXTDOMAIN}.po

    sed -i "s/Automatically generated/${myEMAIL}/" ${ATEXTDOMAIN}.po

    BINMSG="An editable .po file has been created. Edit, then Save, then Quit text editor..."

    ;;
  esac #-------------------------------------------------------

  ROPID=0 ; POPCOL='yellow'
  poptop_func "$BINMSG" $POPCOL

  ABORTFLG=0
  edit_until_error_free_or_break
  if [ $ABORTFLG -eq 0 ];then #130502
   HYBR=
   [[ "$(cat $CACHE/HYBR 2>/dev/null)" =~ "$ATEXTDOMAIN" ]] && HYBR=HYBR

   # [ "$HYBR" ] && echo "HYBR: "
   if [ "$HYBR" = "HYBR" ]; then # new hybrid METHODs (different METHODs for same TEXTDOMAIN)
   
	echo "msgid  \"\"
msgstr \"\"
\"Language: ${transLANG}\n\"
\"Content-Type: text/plain; charset=UTF-8\n\"" > $WD/${ATEXTDOMAIN}_gettext.po
      
    extract_blocks_containing '^#: ' $WD/${ATEXTDOMAIN}.po >> $WD/${ATEXTDOMAIN}_gettext.po
    msgfmt --output-file=$WD/${ATEXTDOMAIN}.mo $WD/${ATEXTDOMAIN}_gettext.po

    extract_blocks_containing '^# _M_' $WD/${ATEXTDOMAIN}.po > $WD/${ATEXTDOMAIN}_t12s.po
    t12s_msgfmt $WD/${ATEXTDOMAIN}_t12s.po > $WD/${ATEXTDOMAIN} 

    rm $WD/${ATEXTDOMAIN}_gettext.po $WD/${ATEXTDOMAIN}_t12s.po # remove # for tests
 
    MESSAGE="The file $WD/${ATEXTDOMAIN}.po has been edited and converted to $WD/${ATEXTDOMAIN}.mo and $WD/${ATEXTDOMAIN}. If all went well, click the \ZbOK\ZB button to copy them to \Zb${AMOSPEC} ${AMOSPEC//.mo/}\ZB."

    [ "$EXIT" = "edit_mo" ] && MESSAGE="$MESSAGE Note, as a precaution, the old translation/mo files are at $WD/${ATEXTDOMAIN}1.moOLD and $WD/${ATEXTDOMAIN}2.moOLD."

   else # old METHODs (one METHOD only for a TEXTDOMAIN)

	eval $(eval get_prop $ASCRIPT)
    case $METHOD in
     gettext|mdview )
      LANG=${ORIGLANG} rxvt -e msgfmt --output-file=$WD/${ATEXTDOMAIN}.mo $WD/${ATEXTDOMAIN}.po 
      MESSAGE="The file $WD/${ATEXTDOMAIN}.po has been edited and converted to $WD/${ATEXTDOMAIN}.mo. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB."
      ;;
     t12s)
	  echo "t12s_msgfmt $WD/${ATEXTDOMAIN}.po > $WD/${ATEXTDOMAIN}"
      t12s_msgfmt $WD/${ATEXTDOMAIN}.po > $WD/${ATEXTDOMAIN}
      MESSAGE="The file $WD/${ATEXTDOMAIN}.po has been edited and converted to $WD/${ATEXTDOMAIN}. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB."
      ;;
    esac
 
    [ "$EXIT" = "edit_mo" ] && MESSAGE="$MESSAGE Note, as a precaution, the old mo file is at $WD/${ATEXTDOMAIN}.moOLD."

   fi

   pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --yesno "$MESSAGE" 0 0
   ABORTFLG=$?

  fi

  if [ $ABORTFLG -eq 0 ]; then #130502
	tarball_mo
	update_cache 
  else						# aborted
	case $EXIT in
		edit_mo) 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 ;;
		create_mo) pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You have declined to create the mo file. OK. Do it later." 0 0 ;;
	esac
  fi

  export LANG=$ORIGLANG 
  exec $thisSCRIPT reenter
  
}   # /edit_create_mo


 edit_create_desk () {

  #131028 want to ALWAYS add translation for Comment
  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/ #131028 
  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/ #131028 
   #sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" /usr/share/applications/$DESKFILE #131028 
  fi
  P_DESKFILE=/usr/share/applications/$DESKFILE #131028 
  cp -f -a $P_DESKFILE $WD/ #131028 

  #grep "Name\[${ORIGLANG1}\]=" $P_DESKFILE || sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" $P_DESKFILE #131028 
  #if [ "$isFATDOG" ]; then
  # grep "GenericName\[${ORIGLANG1}\]=" $P_DESKFILE || sed -i -e "s%GenericName=%GenericName[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nGenericName=%" $P_DESKFILE #150314 also for GenericName (razor menu)
  #fi
  #grep "Comment[${ORIGLANG1}]=" $P_DESKFILE || sed -i -e "s%^Comment=%Comment[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\n%" $P_DESKFILE #131028 

  for ITEM in GenericName Name Comment
  do
   grep "^${ITEM}\[${transLANG}\]=" $P_DESKFILE && continue 
   [ "$isFATDOG" ] || { [ "$ITEM" = "GenericName" ] && continue ; } # GenericName for Fatdog only

   # insert LINE for translation of existing ITEM
   insertLINE="${ITEM}\[${transLANG}\]=${translateNOTE}"
   L="`grep -m 1 "^${ITEM}=" $P_DESKFILE`"
   [ "${L}" ] && sed -i "s%^${L}%${L}\\n${insertLINE}%" $P_DESKFILE && sync
  done #150428 
 
  [ "$APKGNAME" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--
  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.

  # delete LINEs of not translated ITEMs
  sed -i '/INSERT YOUR TRANSLATION HERE/d' /usr/share/applications/$DESKFILE  

  if [ "$xASTAT1" = "$xASTAT2" ];then # no change
   export LANG=$ORIGLANG
   exec $thisSCRIPT reenter
  fi
  
  if [ $POPUPFLAG -eq 1 ];then #150308
   popup 'name=mmpop4 background=#80FF80 terminate=3 level=top|The menu is being updated...'
  else
   yaf-splash -bg '#80FF80' -timeout 3 -text "The menu is being updated..." &
  fi
  
  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/
  cp -f /usr/share/applications/$DESKFILE $MOMADIR #131028
  #add translation to tarball that user can email to pkg author...
  #cd /root
  cd $MOMADIR #131015
  mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/applications
  cp -f /usr/share/applications/$DESKFILE $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/applications/
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} DESKTOP_FILE='/usr/share/applications/${DESKFILE}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
  #cd /root
  cd $MOMADIR #131015
  mv -f MoManager-${transLANG}-${APKGNAME}.tar.gz MoManager-${transLANG}-${APKGNAME}.tar.gzOLD 2>/dev/null

  dir2tgz MoManager-${transLANG}-${APKGNAME} / #150314
  tarball_func
  export LANG=$ORIGLANG
  if [ "$EXIT" != "edit_desk" ];then
   #no_to_yes $CACHE/NODESK_XML "${APKGNAME}" $CACHE/YESDESK_XML  # update YESDESK_XML NODESK_XML #130505
   no_to_yes $CACHE/NODESK_XML "${DESKFILE}" $CACHE/YESDESK_XML  # update YESDESK_XML NODESK_XML #130519
  fi
  exec $thisSCRIPT reenter

}   # end of edit_create_desk)


edit_create_top () {
	
  APKGNAME='WOOF'
  if [ "$EXIT" = "edit_top" ];then
   TOPFILE="$YESTOP_COMBO"
   cp -f -a /usr/share/desktop-directories/$TOPFILE $WD/
  else
   TOPFILE="$NOTOP_COMBO"
   cp -f -a /usr/share/desktop-directories/$TOPFILE $WD/

   #sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" /usr/share/desktop-directories/$TOPFILE
   for ITEM in Name
   do
    L="`grep ^${ITEM}= /usr/share/desktop-directories/$TOPFILE`"
    [ "${L}" ] && sed -i "s%${L}%${L}\\n${ITEM}\[${transLANG}\]=${translateNOTE}%" /usr/share/desktop-directories/$TOPFILE
   done #150314 

  fi
  [ "$TOPFILE" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--
  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 'INSERT YOUR TRANSLATION HERE' /usr/share/desktop-directories/$TOPFILE`" != "" ]; then
    mv -f $WD/$TOPFILE /usr/share/desktop-directories/
    xASTAT2="$xASTAT1"
  fi
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec $thisSCRIPT reenter
  fi
  if [ $POPUPFLAG -eq 1 ];then #150308
   popup 'name=mmpop5 background=#80FF80 terminate=3 level=top|The menu is being updated...'
  else
   yaf-splash -bg '#80FF80' -timeout 3 -text "The menu is being updated..." &
  fi
  if [ "$isFATDOG" ]; then : ; else #150313     
   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
  fi #150313
  #cp -f /usr/share/desktop-directories/$TOPFILE /root/ # 150313 was superfluos because we have MOMADIR now
  #add translation to tarball that user can email to pkg author...
  #cd /root
  cd $MOMADIR #131015  
  mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/applications
  cp -f /usr/share/desktop-directories/$TOPFILE $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/applications/
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} CATEGORY_FILE='/usr/share/desktop-directories/${TOPFILE}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
  #cd /root
  cd $MOMADIR #131015  
  mv -f MoManager-${transLANG}-${APKGNAME}.tar.gz MoManager-${transLANG}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${transLANG}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  #if [ "$EXIT" != "edit_top" ];then # update $CACHE/.... nothing to do #130505

  exec $thisSCRIPT reenter

} # end of edit_create_top)


edit_create_sss () { # #BK's Simple String Substitution method.
	
 case $EXIT in
 
  create_sss)	
  
  APKGNAME="WOOF"
  SSSFILE="$NOSSS_COMBO" #ex: menu_strings (located at /usr/share/sss/menu_strings/)
  [ "$SSSFILE" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--
  cp -f /usr/share/sss/$SSSFILE/$SSSFILE $WD/$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.
    let 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 $MOMADIR/MoManager-${transLANG}-${APKGNAME}${DIRTRANSLATIONFILE}
    cp -a -f "${SSS_TRANSLATION_FILE}" $MOMADIR/MoManager-${transLANG}-${APKGNAME}${DIRTRANSLATIONFILE}/
    echo "MACTION=${EXIT} TODAY_DATE=${ADATE} TRANS_FILE='${SSS_TRANSLATION_FILE}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${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 $MOMADIR/MoManager-${transLANG}-${APKGNAME}
   echo "MACTION=${EXIT} TODAY_DATE=${ADATE} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
   mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   cp -f /usr/share/sss/${SSSFILE}/$SSSFILE.$ORIGLANG1 $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   export LANG=$ORIGLANG
   exec $thisSCRIPT 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 "$WD/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor $WD/$SSSFILE.$ORIGLANG1
  xASTAT2="`stat --format=%Y "$WD/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec $thisSCRIPT 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 $WD/$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)

  if [ $POPUPFLAG -eq 1 ];then #150308
   popup 'name=mmpop5 background=#80FF80 terminate=3 level=top|The desktop and menus are being updated...'
  else
   yaf-splash -bg '#80FF80' -timeout 3 -text "The desktop and menus are being updated..." &
  fi
  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}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
  mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  cp -f $WD/$SSSFILE.$ORIGLANG1 $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  #cd /root
  cd $MOMADIR #131015  
  mv -f MoManager-${transLANG}-${APKGNAME}.tar.gz MoManager-${transLANG}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${transLANG}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec $thisSCRIPT 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
  #[ "$SSSFILES" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--
  [ "$SSSFILE" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty-- #13 0612
  #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.
    let 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 $MOMADIR/MoManager-${transLANG}-${APKGNAME}${DIRTRANSLATIONFILE}
    cp -a -f "${SSS_TRANSLATION_FILE}" $MOMADIR/MoManager-${transLANG}-${APKGNAME}${DIRTRANSLATIONFILE}/
    echo "MACTION=${EXIT} TODAY_DATE=${ADATE} TRANS_FILE='${SSS_TRANSLATION_FILE}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${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 $MOMADIR/MoManager-${transLANG}-${APKGNAME}
   echo "MACTION=${EXIT} TODAY_DATE=${ADATE} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
   mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   cp -f /usr/share/sss/${SSSFILE}/$SSSFILE.$ORIGLANG1 $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
   export LANG=$ORIGLANG
   exec $thisSCRIPT 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 "" > $WD/$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]' >> $WD/$SSSFILE.$ORIGLANG1
     echo "$ENCODEBLOCK" >> $WD/$SSSFILE.$ORIGLANG1
     echo  >> $WD/$SSSFILE.$ORIGLANG1
    ;;
    *)
     echo "[${ASECTIONID}]" >> $WD/$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" >> $WD/$SSSFILE.$ORIGLANG1 #match, so keep it.
       ;;
       *)
        echo "$ATRLINE" >> $WD/$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" >> $WD/$SSSFILE.$ORIGLANG1 #new line not in translated sss-file, so write it (not yet translated).
       ;;
      esac
     done
     echo  >> $WD/$SSSFILE.$ORIGLANG1
    ;;
   esac
  done
  echo  >> $WD/$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 "$WD/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  LANG=${ORIGLANG} defaulttexteditor $WD/$SSSFILE.$ORIGLANG1
  xASTAT2="`stat --format=%Y "$WD/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  if [ "$xASTAT1" = "$xASTAT2" ];then
   export LANG=$ORIGLANG
   exec $thisSCRIPT 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 $WD/$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)
  if [ $POPUPFLAG -eq 1 ];then #150308
   popup 'name=mmpop6 background=#80FF80 terminate=3 level=top|The desktop and menus are being updated...'
  else
   yaf-splash -bg '#80FF80' -timeout 3 -text "The desktop and menus are being updated..." &
  fi
  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}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
  mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  cp -f $WD/$SSSFILE.$ORIGLANG1 $MOMADIR/MoManager-${transLANG}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  #cd /root
  cd $MOMADIR #131015  
  mv -f MoManager-${transLANG}-${APKGNAME}.tar.gz MoManager-${transLANG}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${transLANG}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  exec $thisSCRIPT reenter
  ;;
 esac
  
} # end edit_create_sss


edit_create_xml () {

  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
  [ "$APKGNAME" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--
  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 $thisSCRIPT reenter
  fi
  #add translation to tarball that user can email to pkg author...
  #cd /root
  cd $MOMADIR #131015  
  PATHXMLFILE="`dirname "$XMLFILE"`"
  BASEXMLFILE="`basename "$XMLFILE"`"
  mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}"${PATHXMLFILE}"
  cp -f "$XMLFILE" $MOMADIR/MoManager-${transLANG}-${APKGNAME}"${PATHXMLFILE}"/
  echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} CATEGORY_FILE='${XMLFILE}' AUTHOR='${AUTHORSPECS}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
  #cd /root
  cd $MOMADIR #131015  
  mv -f MoManager-${transLANG}-${APKGNAME}.tar.gz MoManager-${transLANG}-${APKGNAME}.tar.gzOLD 2>/dev/null
  dir2tgz MoManager-${transLANG}-${APKGNAME}/
  tarball_func
  export LANG=$ORIGLANG
  if [ "$EXIT" != "edit_xml" ] ; then
   #no_to_yes $CACHE/NOXML_XML "${APKGNAME}" $CACHE/YESXML_XML  # update YESXML_XML NOxml_XML #130505
   no_to_yes $CACHE/NOXML_XML "${XMLFILE}" $CACHE/YESXML_XML  # update YESXML_XML NOxml_XML #130519
  fi
  exec $thisSCRIPT reenter

} #end edit_create_xml



edit_create_bin	()  {

  if [ "$EXIT" = "edit_bin" ];then
  
   YESBIN_COMBO="${YESBIN_COMBO#*${SEPARATOR}}" #cut -d "$SEPARATOR" -f2- 
   ABIN="`echo -n "$YESBIN_COMBO" | cut -f1 -d'(' | rev | cut -f2-9 -d' ' | rev`"

   ANAME="`basename "$ABIN"`"
   ATRANSLANG="`echo -n "$YESBIN_COMBO" | cut -f2 -d'(' | cut -f1 -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 			#create_bin

   NOBIN_COMBO="${NOBIN_COMBO#*${SEPARATOR}}" # cut -d "$SEPARATOR" -f2- 
   #ABIN="`echo -n "$NOBIN_COMBO" | cut -f 1 -d '(' | rev | cut -f 2 -d ' ' | rev`"
   ABIN=${NOBIN_COMBO%% *}

   #APKGNAME="`echo -n "$NOBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: bluefish  ex: WOOF
   A=${NOBIN_COMBO##*(} && A=${A%)*} && APKGNAME=${A#* }

   #ATEXTDOMAIN="`echo -n "$NOBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`"
   ATEXTDOMAIN=${NOBIN_COMBO#*(} && ATEXTDOMAIN=${ATEXTDOMAIN% *}

   FIELD2ND="`echo -n "$ORIGLANG12" | cut -f 2 -d '_'`"

   [ "$ABIN" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--


   #if [ "$transLANG" != "${ORIGLANG1}" -a "$transLANG" != "${ORIGLANG12}" ]; then #150309
   if [ $FIRSTRUN -eq 1 ];then #150309
    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

    sed -i "s%^transLANG=.*%transLANG=${ATRANSLANG} #${ORIGLANG1} or ${ORIGLANG12}%" $CONFIG #150309
    transLANG=${ATRANSLANG} #150309
   else #150309
    ATRANSLANG="$transLANG"
   fi
   ANAME="`basename "$ABIN"`"
   AMO="${ATEXTDOMAIN}.mo"
  fi
#echo BIN=$ABIN 
  [ "$ABIN" ] || LANG=$ORIGLANG exec $thisSCRIPT restart # 130604 --empty--

  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
  
  ATRANSLANG=$transLANG
  AMOSPEC="${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  mkdir -p "${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES" #120308
  cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot $WD/
  cd $WD
ls
  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" $WD/${ATEXTDOMAIN}.moOLD
  else
   if [ "$EXIT" = "edit_bin" ];then
    cp -f "$AMOSPEC" $WD/${ATEXTDOMAIN}.moOLD
    msgunfmt --no-wrap "$AMOSPEC" > $WD/${ATEXTDOMAIN}1.po

    #this syncs textdomain1.po and textdomain.pot, merges to textdomain.po ...
    rm -f ${ATEXTDOMAIN}.po 2>/dev/null
    LANG=${ORIGLANG} rxvt -e msgmerge --no-wrap $NOFUZZY ${ATEXTDOMAIN}1.po ${ATEXTDOMAIN}.pot --output-file=${ATEXTDOMAIN}.po ; #130525 

    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-translator --no-wrap --locale=${transLANG} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot 
     sed -i "s/Automatically generated/${myEMAIL}/" ${ATEXTDOMAIN}.po  #130603

     LANG=${ORIGLANG} defaulttextviewer $WD/${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..."
     POPCOL='LightPink'
    fi

   else  # create_bin
    LANG=${ORIGLANG} rxvt -e msginit --no-translator --no-wrap --locale=${transLANG} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot #130603
    if [ "${transLANG%_*}" = "en" ]; then
     strip_po ${ATEXTDOMAIN}.po > s_${ATEXTDOMAIN}.po
     sync && mv s_${ATEXTDOMAIN}.po ${ATEXTDOMAIN}.po
	fi
    sed -i "s/Automatically generated/${myEMAIL}/" ${ATEXTDOMAIN}.po
   fi
  fi
  sync
 
  poptop_func "$BINMSG" $POPCOL
  zASTAT1="`stat --format=%Y $WD/${ATEXTDOMAIN}.po`" #120309 modify date, seconds.
  
  ROPID=0
  ABORTFLG=0
 
  METHOD='gettext'  # this must be set for gettexted binaries
  edit_until_error_free_or_break

  if [ $ABORTFLG -ne 0 ]; then
   export LANG=$ORIGLANG
   exec $thisSCRIPT reenter 
  fi 

  [ $ROPID -ne 0 ] && kill $ROPID
  zASTAT2="`stat --format=%Y $WD/${ATEXTDOMAIN}.po`" #120309 modify date.

  if [ "$zASTAT1" = "$zASTAT2" ];then #120309
   export LANG=$ORIGLANG
   exec $thisSCRIPT reenter
  fi

  LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=$WD/${ATEXTDOMAIN}.mo $WD/${ATEXTDOMAIN}.po
  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 $WD/${ATEXTDOMAIN}.po has been edited and converted to $WD/${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 $WD/${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 $WD/${ATEXTDOMAIN}.po /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po
   RETVAL=0
  fi
  if [ $RETVAL -eq 0 ];then
   tarball_mo
   update_cache
  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 $thisSCRIPT reenter

} #end edit_create_bin 

pref () {

  while true; do
   killall geany 2>/dev/null #150308
   sleep 0.5
   defaulttexteditor $CONFIG
   #150309 do not allow transLANG to be changed to anything other than current locale
   # (note, if was allowed, would have to check /usr/lib/locale has it, but I still don't like idea of translating to a different language then current locale).
   xtransLANG="$(grep '^transLANG' $CONFIG | cut -f2 -d= | cut -f1 -d' ')"
   if [ "$(echo -n "$ORIGLANG12" | grep "$xtransLANG")" == "" ];then
    pupdialog --background '#FF8080' --msgbox "Sorry, but you cannot change transLANG to anything other than the current locale, '${ORIGLANG1}' or '${ORIGLANG12}'. Changing transLANG to '${ORIGLANG1}'" 0 0
    sed -i "s%^transLANG=.*%transLANG=${ORIGLANG1} #${ORIGLANG1} or ${ORIGLANG12}%" $CONFIG
   fi
   . $CONFIG
   [ "$showINTRO" -a "$transLANG" -a "$myEMAIL" ] && break #131014
  done
  LANG=$ORIGLANG exec $thisSCRIPT reenter

} # end pref


menu_combos_with_HELP () { # MENU ENTRIES # and # categories #

 #######MENU ENTRIES#######
 #time was 28.8sec
 if [ ! -f $CACHE/YESDESK_XML ] ; then #130505
 #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 2 -type f -name '*.desktop' | grep -v ' ' | sort --ignore-case | tr '\n' ' '`
 do
  [ "`grep '^Icon' $ADESKTOP`" = "" ] && continue #some dummy .desktop files used by xfce, ignore them.
  #ADESKNAME="${ADESKTOP##*\/}" #basename
  ADESKNAME="${ADESKTOP//\/usr\/share\/applications\//}" #160205 for maxdepth > 1
 
  #find out what package it is from...
  xPTN=" ${ADESKNAME}$"
  zPTN="^${ADESKTOP}$"
  #test if pkg used in Woof build.
  aPKGNAME="`grep -m 1 "$xPTN" /root/.packages/builtin_files/* `"
  aPKGNAME="${aPKGNAME%%:*}"
  aPKGNAME="${aPKGNAME##*\/}"

  ##test if user-installed pkg.
  if [ ! "$aPKGNAME" ]; then
   aPKGNAME="`grep -m 1 "$zPTN" /root/.packages/*.files 2>/dev/null `"
   aPKGNAME="${aPKGNAME%%:*}"
   aPKGNAME="${aPKGNAME##*\/}"
   aPKGNAME="${aPKGNAME/\.files/}"
  fi
  
  #...return nothing if in Woof
  [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${ADESKTOP}" ] && aPKGNAME="WOOF" #file is in Woof.
  [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
 
  if [ "`grep "$dPTN" $ADESKTOP`" != "" ];then

   #[ "$isFATDOG" -a "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ] && continue #131206 Fatdog: take just those files that are not in basic langpack #140101

   #if [ "$isFATDOG" -o "$isQUIRKY" ]; then #take just those files that are not in basic langpack #140104
###   if [ "$isQUIRKY" ]; then #take just for quirky #150313
###    [ "`grep ${TEXTDOMAINVALUE}.mo /root/.packages/langpack_${transLANG}-*`" ] && continue
###   fi
###190118

   YESDESK_XML="${YESDESK_XML}
<item>${ADESKNAME} (${aPKGNAME})</item>"
   echo "$ADESKTOP" >> $WD/translations4langpack
  else
   NODESK_XML="${NODESK_XML}
<item>${ADESKNAME} (${aPKGNAME})</item>"
  fi
  done

  echo "$YESDESK_XML" > $CACHE/YESDESK_XML
  echo "$NODESK_XML" > $CACHE/NODESK_XML
 else #130505
  YESDESK_XML="`cat $CACHE/YESDESK_XML`"
  NODESK_XML="`cat $CACHE/NODESK_XML`"
  #echo "proceed using cached data from $CACHE
  #      if you want fresh data clear cache using Refresh button
  #"
 fi #130505

 if [ "$YESDESK_XML" ];then
  YESDESK_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>YESDESK_COMBO</variable>${YESDESK_XML}</combobox>"
 else
  #YESDESK_XML="<text><label>nothing</label></text>"
  YESDESK_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>EMPTYYESDESK_COMBO</variable><item>--empty--</item></combobox>"
 fi
 if [ "$NODESK_XML" ];then
  NODESK_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>NODESK_COMBO</variable>${NODESK_XML}</combobox>"
 else
  #NODESK_XML="<text><label>nothing</label></text>"
  NODESK_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>EMPTYNODESK_COMBO</variable><item>--empty--</item></combobox>"
 fi

 #help buttons...
 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>'
 YESDESKHELP_XML="<button><input file stock=\"gtk-help\"></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>'
 NODESKHELP_XML="<button><input file stock=\"gtk-help\"></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' ' '`" # time 0.08s
 YESTOP_XML=""; NOTOP_XML=""
 dPTN="^Name\\[${ORIGLANG1}\\]"
 for ATOPMENUFILE in $TOPMENUFILES # time 0.3s
 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}" >> $WD/translations4langpack
  else
   NOTOP_XML="${NOTOP_XML}
<item>${ATOPMENUFILE}</item>"
  fi
 done
 if [ "$YESTOP_XML" ];then
  YESTOP_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>YESTOP_COMBO</variable>${YESTOP_XML}</combobox>"
 else
  #YESTOP_XML="<text><label>nothing</label></text>"
  YESTOP_XML="<combobox width-request=\"$COMBOyesWIDTH\"><variable>EMPTYYESTOP_COMBO</variable><item>--empty--</item></combobox>"
 fi
 if [ "$NOTOP_XML" ];then
  NOTOP_XML="<combobox width-request=\"$COMBOnoWIDTH\"><variable>NOTOP_COMBO</variable>${NOTOP_XML}</combobox>"
 else
  #NOTOP_XML="<text><label>nothing</label></text>"
  NOTOP_XML="<combobox width-request=\"$COMBOnoWIDTH\"><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 stock=\"gtk-help\"></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>'
 NOTOPHELP_XML="<button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_NOTOP</action></button>"


} #end menu_combos_with_HELP


main_window () {

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

 if [ "$transLANG" != "en" ]; then
 TEXT="Translators first, you need to get all of the files on the right-side drop-down lists over to the left-side lists to ${TRANSLATE} to your <b>${transLANG}</b> language. Then, check the left column to update/verify translations."
 else #200606
 TEXT="Developers, here is pseudo translation, just English prepended by '$Xenglish' or whatever you define in configuration. <b>Create</b>"
 [ $(wc -l < $CACHE/NOMO_XML) -gt 1 ] && TEXT="$TEXT all translations for these listed $(wc -l < $CACHE/NOMO_XML ) scripts." || TEXT="$TEXT single translation."
 fi

 if [ -z "$MATCH_TEXTDOMAIN" ]; then
  SUBTITLE="${PUPPY} files"
 else
  #200505
  NUM="$(ls *.pot 2>/dev/null | wc -w)"   # check number
  
  # define name of new pot file: ${TD_NEW}.pot
  y=${#MATCH_TEXTDOMAIN}
  for TD_NEW in ${MATCH_TEXTDOMAIN:0:y}
  do
    [[ "$(ls *.pot 2>/dev/null)" =~ "${TD_NEW}.pot" ]] || break 
    let y=y-1
    if [ $y -lt 2 ]; then
      for TD_NEW in ${MATCH_TEXTDOMAIN^^}_${NUM}_${MATCH_TEXTDOMAIN}  ${MATCH_TEXTDOMAIN^}
      do
        [[ "$(ls *.pot 2>/dev/null)" =~ "${TD_NEW}.pot" ]] || break 
      done
      break
    fi
  done
  
  #SUBTITLE="scripts and md files which TEXTDOMAIN matches '${MATCH_TEXTDOMAIN}'" #140410
  SUBTITLE="files which TEXTDOMAIN matches '${MATCH_TEXTDOMAIN}'" #200317
  
  TEXT2="Developers might check their messages; sort by <b>msgid</b> can be useful for this."
   
  TEXT2a="POT file (and some other files) is to be found in working directory $WD."

  [[ $NUM -gt 1 ]] && TEXT3="
There are ${NUM} TEXTDOMAINs which can automatically be united.
Click button<b> $NUM → 1 </b>to change them to just ONE that is named:
       " #200505
 fi  

 read CHECKED < ${WD}/MATCH_TD_CHECKED ; [ "$CHECKED" = "checked" ] && SUBTITLE="${SUBTITLE/${MATCH_TEXTDOMAIN}/...$MATCH_TEXTDOMAIN...}" || SUBTITLE="${SUBTITLE/${MATCH_TEXTDOMAIN}/$MATCH_TEXTDOMAIN...}" #200505

 MM2_DLG="<window title=\"MoManager-${lastUPDATEofTHISscript} : $SUBTITLE\" resizable=\"false\" icon-name=\"${WINICON}\">
 <vbox>

  <hbox>
   <text use-markup=\"true\" width-request=\"${WINDOW_WIDTH}\"><label>\"$TEXT\"</label></text>
  </hbox>
"

[ "$MATCH_TEXTDOMAIN" ] && MM2_DLG="$MM2_DLG
  <hbox>
   <text use-markup=\"true\" width-request=\"$(echo $((WINDOW_WIDTH)))\"><label>\"$TEXT2\"</label></text>
   </hbox>

   <hbox>
   <text use-markup=\"true\"><label>\"$TEXT2a\"</label></text>
   
   <button use-stock=\"true\" label=\"gtk-info\" tooltip-markup=\"<span>Click to open ${WD} and look what is inside if you like.</span>\">
   <action>rox --close=${WD} && rox --dir=./</action>
   </button>

   <button use-stock=\"true\" label=\"gtk-close\" tooltip-markup=\"<span>Click to close ${WD}.
Does not delete ${WD}, just hide it from the screen.</span>\">
   <action>rox --close=${WD}</action>
   </button>
   
  </hbox>"
 
[[ $NUM -gt 1 ]] && MM2_DLG="$MM2_DLG  
<frame experimental>
  <hbox>
    <text use-markup=\"true\" ><label>\"$TEXT3\"</label></text>
 
     <entry width=\"8\" tooltip-markup=\"<span>Note,
  this new TEXTDOMAIN is <b>case sensitive</b>.
  It has to be <i>really new</i>, i.e. <i>must not</i> already exist.
  Digit at the end is not allowed.</span>\">
    <default>$TD_NEW</default>
    <variable>TD_NEW</variable>
   </entry>  
    
    <button tooltip-markup=\"<span>Click and see how file size changes and
how number of messages decreases.
Nothing will be changed without your confirmation.</span>\"><label> $NUM → 1 </label> <action>EXIT:n_to_1</action></button>

    <button><input file stock=\"gtk-help\"></input><action type=\"launch\">DLG_HELP_N_1</action></button>
  
    </hbox>
  </frame>  
" #200505

 MM2_DLG="$MM2_DLG
  <hbox>
   <vbox>
    <frame "
 
 [ "`grep -m 1 $FUZZIN $CACHE/YESMO_XML`" ] && MM2_DLG="$MM2_DLG ${FUZZIN}fuzzy, " #140228

 #MM2_DLG="$MM2_DLG ${NOTIN}check needed, ${ISIN}up-to-date : Scripts that have a mo file> <hbox>${YESMO_XML}<button><label>Edit</label><action>EXIT:edit_mo</action></button>${YESMOHELP_XML}</hbox>
 MM2_DLG="$MM2_DLG ${NOTIN}check needed, ${ISIN}up-to-date> <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 ${transLANG} mo file>
	 <hbox>${NOMO_XML}
	 <button"

 if [[ "$transLANG" = "en" && "$(wc -l < $CACHE/NOMO_XML)" -gt 1 ]]; then
  MM2_DLG="$MM2_DLG tooltip-markup=\"<span>Create all of these $(cat $CACHE/NOCNT) listed items</span>\""  
 fi 

 MM2_DLG="${MM2_DLG}>
     <label>Create</label>
	   <action>EXIT:create_mo</action>
	  </button>"
	  
 MM2_DLG="${MM2_DLG}
 	  ${NOMOHELP_XML}
     </hbox>
    </frame>
   </vbox>
  </hbox>
"  
 if [ -z "${MATCH_TEXTDOMAIN}" ]; then
  MM2_DLG="$MM2_DLG  
   <hbox>
    <vbox>
     <frame Menu categories with a ${transLANG} 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 ${transLANG} translation>
     <hbox>${NOTOP_XML}<button><label>Create</label><action>EXIT:create_top</action></button>${NOTOPHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
"
  MM2_DLG="$MM2_DLG  
   <hbox>
    <vbox>
     <frame Menu entries with a ${transLANG} 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 ${transLANG} translation>
     <hbox>${NODESK_XML}<button><label>Create</label><action>EXIT:create_desk</action></button>${NODESKHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
"
  if [ ! "$isFATDOG" ]; then #131206  sss simple string substitution
   MM2_DLG="$MM2_DLG  
   <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 ${transLANG} translation>
     <hbox>${NOXML_XML}<button><label>Create</label><action>EXIT:create_xml</action></button>${NOXMLHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>

   <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 ${transLANG} translation>
     <hbox>${NOSSS_XML}<button><label>Create</label><action>EXIT:create_sss</action></button>${NOSSSHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
"
  fi
 fi 
 if [ "${transLANG}" != "en" ]; then #200606
  MM2_DLG="$MM2_DLG  
   <hbox>
    <vbox>
     <frame Binary executables that have a ${transLANG} 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 ${transLANG} mo file>     <hbox>${NOBIN_XML}<button><label>Create</label><action>EXIT:create_bin</action></button>${NOBINHELP_XML}</hbox>
     </frame>
    </vbox>
   </hbox>
"
 fi
 MM2_DLG="$MM2_DLG  
   <hbox>
   ${POEDIT_XML}
   <hbox>
"   
 if [[ $(cat $CACHE/YESCNT) -gt 12 ]]; then
   MM2_DLG="$MM2_DLG 
  <text use-markup=\"true\" width-request=\"120\"><label>Top-left drop-down list $TTT or click button:</label></text>
   <button tooltip-markup=\"<span>drop-down list has <b>$toggle_item_per</b></span>\"> 
   <input file stock=\"gtk-indent\"></input>
    <variable>toggle_YESMO</variable>
   <action>EXIT:toggle_yesmo</action></button>

  <text use-markup=\"true\" width-request=\"12\"><label> .</label></text>
"
 fi
 MM2_DLG="$MM2_DLG 
  <text use-markup=\"true\" width-request=\"78\"><label>Messages sorted by ${SORTby} or click button:</label></text>
   <button tooltip-markup=\"<span>Sort messages in po file by <b>${SORTedby}</b></span>\"> 
   <input file stock=\"gtk-file\"></input>
    <variable>toggle_SORT</variable>
   <action>EXIT:toggle_sort</action></button>

  <text use-markup=\"true\" width-request=\"12\"><label> .</label></text>
"
 MM2_DLG="$MM2_DLG    
  <text use-markup=\"true\" width-request=\"90\"><label>In all po files search for: </label></text>
   <entry width-chars=\"12\" tooltip-markup=\"<span>Note, this search is <b>case sensitive</b>. To find all <i>please</i> and <i>Please</i> type: '<i>please|Please</i>' or just '<i>[p|P]lease</i>' (without the quotes!)</span>.\">
    <default>$searchENTRY</default>
    <variable>searchENTRY</variable>
   </entry>
   <button tooltip-text=\"$ttSEARCH\">
   <input file stock=\"gtk-find\"></input>
   <action>EXIT:search</action></button>
   </hbox>
"   
 [ "${MATCH_TEXTDOMAIN}" ] || MM2_DLG="$MM2_DLG	
   ${PETHELP_XML}
"	
 MM2_DLG="$MM2_DLG
	<button tooltip-markup=\"<span>About momanager</span>\">
	<input file stock=\"gtk-about\"></input>
	<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) \\n\\n \
	 Forked by L18L 2013 for faster usage and for Fatdog. \n \
	 Also usable with md files for documentation and READMEs.\n \
	 Since 2017 Alphabetic sorting of messages, for English, too.\n \
	 2019 Updated for EasyOS. \\n\\n \
	Current version of momanager is $lastUPDATEofTHISscript.' 0 0 & </action></button>
   
   <button tooltip-text=\"Preferences: change some defaults in a text editor.\">
   <input file stock=\"gtk-preferences\"></input>
   <action>EXIT:preferences</action></button>
"
 MM2_DLG="$MM2_DLG	
	<button tooltip-markup=\"<span><b>Refresh</b> clears cache and start again. Will take a while...</span>\">
	<input file stock=\"gtk-refresh\"></input>
	<action>EXIT:refresh</action></button>
"
 [ "${MATCH_TEXTDOMAIN}" ] || MM2_DLG="$MM2_DLG 
   <button tooltip-markup=\"<span>Create a <b>${LANGPACK}_${transLANG}</b>.</span>\"> 
   <input file stock=\"gtk-yes\"></input>
   <action>EXIT:create_pet</action></button>
"
 MM2_DLG="$MM2_DLG 	
	<button tooltip-text=\"Quit momanager.\">
	 <input file stock=\"gtk-quit\"></input>
  	 <action>EXIT:quit</action>
  	</button>
   </hbox>
  </vbox>
 </window>
"
 export MM2_DLG

} # end main_window
export -f main_window

tarball_mo () {  #for all mo files
	
	#pop_up "Please wait, creating tarball MoManager-${transLANG}-${APKGNAME}.tar.gz..."
	#170815
	echo "Please wait, creating tarball MoManager-${transLANG}-${APKGNAME}.tar.gz...
"
	
	#create directory if not there
	#copy translation to its location
    case "$METHOD" in
		t12s)	mkdir -p $TEXTDOMAINDIRVALUE/${transLANG}
				cp -f $WD/${ATEXTDOMAIN} ${TEXTDOMAINDIRVALUE}/${transLANG}/${ATEXTDOMAIN}
				
				mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}${TEXTDOMAINDIRVALUE}/${transLANG}

				;;
           *)	mkdir -p ${TEXTDOMAINDIRVALUE}/${transLANG}/LC_MESSAGES
           		cp -f $WD/${ATEXTDOMAIN}.mo ${TEXTDOMAINDIRVALUE}/${transLANG}/LC_MESSAGES/

				mkdir -p $MOMADIR/MoManager-${transLANG}-${APKGNAME}${TEXTDOMAINDIRVALUE}/${transLANG}/LC_MESSAGES
           		;;
    esac

	#output as a tarball that user can email to pkg author...
	cp -f $WD/${ATEXTDOMAIN}.mo $MOMADIR/MoManager-${transLANG}-${APKGNAME}${TEXTDOMAINDIRVALUE}/${transLANG}/LC_MESSAGES/  2>/dev/null

	cp -f $WD/${ATEXTDOMAIN}	$MOMADIR/MoManager-${transLANG}-${APKGNAME}${TEXTDOMAINDIRVALUE}/${transLANG}/ 2>/dev/null


	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}'" >> $MOMADIR/MoManager-${transLANG}-${APKGNAME}/write.log
   
	cd $MOMADIR
	mv -f MoManager-${transLANG}-${APKGNAME}.tar.gz MoManager-${transLANG}-${APKGNAME}.tar.gzOLD 2>/dev/null
	dir2tgz MoManager-${transLANG}-${APKGNAME}/

	tarball_func

} #end tarball_mo


tarball_func() { #for all translation files 
	
	if [ "$isFATDOG" ] ; then	
		TARBALLMSG="Translation files that you have created with MoManager have been copied into folder \Zb$MOMADIR/MoManager-${transLANG}-${APKGNAME}\ZB, and a tarball has been created, \Zb$MOMADIR/MoManager-${transLANG}-${APKGNAME}.tgz\ZB. Note, it contains \Zbwrite.log\ZB which records the details of each translation file.
The tarball can be sent to whoever is wanting to test it.
When you have it working nicely, send it to the Fatdog64 thread in the Puppy Forum."
	else
		TARBALLMSG="Translation files that you have created with MoManager have been copied into folder \Zb$MOMADIR/MoManager-${transLANG}-${APKGNAME}\ZB, and a tarball has been created, \Zb$MOMADIR/MoManager-${transLANG}-${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:
\Zbde\ZB L18L
\Zbes\ZB vicmz
\Zbfr\ZB esmourguit
\Zbpl\ZB robwoj44
\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."
	fi
	pupdialog --background green --colors --backtitle "MoManager: edit completed" --msgbox "${TARBALLMSG}" 0 0

} #end tarball_func


create_NLS_update () {
	
 #Fatdog does not have langpack
 #Fatdog has fd64-nls_xxx.sfs for all languages
 #the file that has to be created here is to be used for update of nls.sfs
 #thus let us call it SP (Service Pack)
 #name of SP should include: fatdog nls version language date 
 # compressed as tar.gz
 
 . /etc/DISTRO_SPECS
 SP=${DISTRO_FILE_PREFIX}-nls_$(cat /etc/fatdog-nls-version)_${transLANG}-${ADATE} #ex:fd64-nls_701_de-20150430
 upd=${SP}/update

 rm -rf $SP
 mkdir -p $SP

 TEXT="Transitional ${GENLANG} service pack for Fatdog to be merged with Fatdog's universal NLS package ${DISTRO_FILE_PREFIX}-nls_$(cat /etc/fatdog-nls-version).sfs"  # TEXT for package info ???  

 # merge all MoManager-${LANG1}: (MoManager-${LANG1}-  MoManager-${LANG1}-UNKNOWN  MoManager-${LANG1}-WOOF)
 for D in `ls -d ${MOMADIR}/MoManager-*                   `
 do
  case $D in *\.gz*) continue ;; esac
  cp -a $D/usr $SP
 done  
 
 # translations of desktop-directories are also under applications 
 # extract translations for this language
 cd ${SP}/usr/share
 for ITEM in Name GenericName Comment
 do
  grep "^${ITEM}\[${transLANG}\]=" applications/* >> ../../update
 done
 rm -rf applications # we use just the data in $upd
 cd -

 # fix the wrong thing of desktop-directories (see 5 lines down)
 # this does not work:
 # sed -i '#\.directory:#s#applications/#desktop-directories/#' $upd
 # thus do it this way:
 mv ${upd} ${upd}_

 echo "# update NLS for desktop files in /usr/share
# " > $upd 

 grep '\.directory\:' ${upd}_ | sed 's#applications/#desktop-directories/#' >> ${upd}
 grep -v '\.directory\:' ${upd}_ >> ${upd}
 rm  ${upd}_

 mkdir ${SP}/install ; echo "#!/bin/sh
update-desktop-files-i18n.sh ../update
" > ${SP}/install/doinst.sh
 chmod +x ${SP}/install/doinst.sh

 dir2tgz ${SP}
  
 kill `pidof yaf-splash` $sPID 2>/dev/null

 pupdialog --background '#8080FF' --backtitle "NLS ServicePack created" --msgbox "ServicPack  ${SP}.tar.gz has been created." 0 0

} #end of create_NLS_update


fuzzy_find () {

 [ -f $WD/${ATEXTDOMAIN}1.po ] && rm -f $WD/${ATEXTDOMAIN}1.po $WD/${ATEXTDOMAIN}2.po 2>/dev/null #151230 2> 170701
 cd $WD	
 
 #grep -A 2 -H -n -s 'fuzzy' `ls *.po 2>/dev/null` > fuzz
 grep -A 3 -H -n -s 'fuzzy' `ls *.po 2>/dev/null` > fuzz
    # -A 3 -> msgid  msgstr  blanc
    #      or msgid  msgid_plural msgstr[0] 
  
 if [ -f $WD/fuzz ]; then
  cat $WD/fuzz > $CACHE/fuzzies
  NUM_FUZZ_FILES="`grep fuzzy $CACHE/fuzzies | cut -d: -f1 | uniq | wc -l`" #number of 'fuzzy' po files 
  NUM_FUZZ_ENTRY="`grep msgstr $CACHE/fuzzies |  wc -l`" #number of 'fuzzy' entries

  echo -n "___________________________________________________

Check these translations and then delete \"fuzzy\" line.

found $NUM_FUZZ_ENTRY fuzzy translations in $NUM_FUZZ_FILES files" >> $CACHE/fuzzies
 else
  echo -n "
---
No fuzzy found" > $CACHE/fuzzies
 fi
 echo " at `date`" >> $CACHE/fuzzies #170616

 #update $CACHE/YESMO_XML , ex:
 #change <item>…bootmanager→/usr/sbin/bootmanager (de bootmanager.mo WOOF)</item>
 #to     <item>░bootmanager→/usr/sbin/bootmanager (de bootmanager.mo WOOF)</item> 
 grep '#, fuzzy' $CACHE/fuzzies | cut -d':' -f1 | uniq | while read LINE
 do
  CHANGE_THIS="`grep -m 1 " ${LINE/.po/} " $CACHE/YESMO_XML`"
  [ "$CHANGE_THIS" ] || CHANGE_THIS="`grep -m 1 ${LINE} $CACHE/YESMO_XML`"
  [ "$CHANGE_THIS" ] || continue
  
  CHANGE_TO="`echo $CHANGE_THIS | sed s#${ISIN}#${FUZZIN}# `"
  sed -i --follow-symlinks "s#$CHANGE_THIS#$CHANGE_TO#g" "$CACHE/YESMO_XML"
  # --follow-symlinks ---> YESMO_XML_ALL and YESMO_XML_ONE
  CHANGE_TO="`echo $CHANGE_THIS | sed s#${NOTIN}#${FUZZIN}# `"
  sed -i --follow-symlinks "s#$CHANGE_THIS#$CHANGE_TO#g" "$CACHE/YESMO_XML"
 done
 cd - 1>/dev/null
 
} #end of fuzzy_find

fuzzy_use () {

 kill_all_windows_titled 'At first please edit'

 if [ -f "$CACHE/fuzzies" ]; then
  if [ "`tail -n 1 $CACHE/fuzzies | cut -d' ' -f1-2`" != "found 0" ]; then 
   fuzzy_find
   #no utf8 possible 20170616
   #exec urxvt --title "MoManager : At first please edit these Fuzzy Translations"  -e dialog --textbox $CACHE/fuzzies  0 0 & 

   #utf8 tested OK 20170616
   Xdialog --no-cancel --ok-label Close --title "MoManager : At first please edit these Fuzzy Translations" --tailbox $CACHE/fuzzies  25 70 & 
  fi
 fi
 
} #end of fuzzy_use


update_transl () {
	 
 # force refresh
### rm -rf $WD #/tmp/momanager
 # restart
 cd /root
 
 #LANG=$ORIGLANG exec $thisSCRIPT createApet
 #new code  to betested:
 [ "$isFATDOG" ] && create_NLS_update ||  create_a_pet #150829
 LANG=$ORIGLANG exec $thisSCRIPT
 
} #end update_transl

n_to_1_preview () { #200808

  # unite several TEXTDOMAINS into one new TEXTDOMAIN
  # reducing number of TEXTDOMAINs will make translators' (and maintainers') lifes easier
  # L16L Jul-Aug 2020
  local TD_OLD SCRIPT LA ORIG F LOC MO

  # create ${TD_NEW}.pot and ${TD_NEW}.po
  create_actual_pot_file_header 
  msginit --no-translator -l ${transLANG} -i ${TD_NEW}.pot -o ${TD_NEW}.po || die "${TD_NEW}.po not created"

  # fill TD_NEW}.po
  for F in $(ls ${MATCH_TEXTDOMAIN}*.po)
  do
    case "$F" in
         *1.po) continue ;;
         *2.po) continue ;;
         *3.po) continue ;;
  ${TD_NEW}.po) continue ;;
          *) # echo "grep -A 9999 '^$' ${F} >> ${TD_NEW}.po"
             # anything behind included first blanc line
             grep -A 9999 '^$' ${F} >> ${TD_NEW}.po
             ;;
    esac
  done

  # count  messages and file sizes
  MSGs=0
  MOsize=0
  while read SCRIPT LA TD_OLD ORIG #ex: <item>…ui_Classic→/usr/local/petget/ui_Classic (de  petget___ui_Classic UNKNOWN)</item>
  do
    MO=${TD_OLD}1.moOLD
    [ -f ${MO} ] || MO=${TD_OLD}.mo 
    let      MSGs=$MSGs+$(file ${MO} | cut -d' ' -f9)
    let MOsize=$MOsize+$(ls -l ${MO} | cut -d' ' -f5)
  done < ${CACHE}/YESMO_XML
  echo "
  msguniq -u ${TD_NEW}.po"
  msguniq -u ${TD_NEW}.po > ${TD_NEW}_u.po
          mv ${TD_NEW}_u.po ${TD_NEW}.po

  if [ "$transLANG"="en" ]; then
    sed -e "s/${Xenglish}\\\n/\\\n${Xenglish}/" ${TD_NEW}.po > ${TD_NEW}_.po
    mv ${TD_NEW}_.po ${TD_NEW}.po
    sync
  fi

  # create ${TD_NEW}.mo
  echo msgfmt -o "${TD_NEW}.mo" ${TD_NEW}.po 
  msgfmt -o "${TD_NEW}.mo" ${TD_NEW}.po 

  echo MOsize=$MOsize
  echo MSGs=$MSGs
  echo -n 'file ' && file "${TD_NEW}.mo"
  ls -l ${TD_NEW}.mo
  
  # cache number of messages and file sizes
  echo $MOsize > ${WD}/MOsize
  echo $MSGs > ${WD}/MSGs
  echo $TD_NEW > ${WD}/TD_NEW
  ls -l ${TD_NEW}.mo | cut -d' ' -f5 > ${WD}/MOsizeNEW
  file  ${TD_NEW}.mo | cut -d' ' -f9 > ${WD}/MSGsNEW
  
  rm ${TD_NEW}.po ${TD_NEW}.pot

                 LANG=$ORIGLANG exec $thisSCRIPT reenter "MATCH_TEXTDOMAIN=$TD_NEW"


}
export -f n_to_1_preview

n_to_1 () { #200808
 
  # check new TEXTDOMAIN
  if [ "$(find /usr -name ${TD_NEW}.mo)" ]; then
    ERR="TEXTDOMAIN ${TD_NEW}
already exists
choose another name "
  fi
  case "${TD_NEW:(-1)}" in
      [0-9]) ERR="TEXTDOMAIN ${TD_NEW}
no trailing digit allowed
choose another TEXTDOMAIN name " ;;
  esac 
  if [ "$ERR" ]; then
    pop_up "$ERR"
    sleep 5
    LANG=$ORIGLANG exec $thisSCRIPT reenter "MATCH_TEXTDOMAIN=$(cat MATCH_TEXTDOMAIN)"
   fi
  
  # perform  n_to_1_preview just once
  [ -f ${WD}/MOsize ] || n_to_1_preview
  [ -f ${TD_NEW}.mo ] || die "no ${TD_NEW}.mo file"

  # confirm
  HELP="Yes: Change will be performed 
  No: no action, return to main window"
  CONFIRM="  
       ACTUAL: $NUM mo files   $MOsize bytes  and  $MSGs  messages  
         
         NEW:  1  ${TD_NEW}.mo   $(cat ${WD}/MOsizeNEW)  bytes  and  $(cat ${WD}/MSGsNEW) messages  
         
         Confirm change from ACTUAL to NEW ?
"
  Xdialog --wrap --title "Let it be or not let it be"\
          --help "$HELP"\
          --yesno "${CONFIRM}" 0 0
  if [ $? -ne 0 ]; then
    LANG=$ORIGLANG exec $thisSCRIPT reenter "MATCH_TEXTDOMAIN=$(cat MATCH_TEXTDOMAIN)"
  fi
  
  # action 
  cp ${TD_NEW}.mo "${TEXTDOMAINDIR:-/usr/share/locale}/${transLANG}/LC_MESSAGES/${TD_NEW}.mo"

  local TD_OLD SCRIPT LA ORIG F LOC MO
  while read SCRIPT LA TD_OLD ORIG #ex: <item>…ui_Classic→/usr/local/petget/ui_Classic (de  petget___ui_Classic UNKNOWN)</item>
  do
    echo "export TEXTDOMAIN=${TD_OLD} -> export TEXTDOMAIN=${TD_NEW}"

    SCRIPT=${SCRIPT#*→} # cut -d'→' -f2) #ex: /usr/local/petget/ui_Classic
    LOC=$(find /usr -name ${TD_OLD}.mo | grep "/${transLANG}/")

    # update TEXTDOMAIN= in scripts
    sed -i "s/export TEXTDOMAIN=${TD_OLD}/export TEXTDOMAIN=${TD_NEW}/" ${SCRIPT} 

    #move old mo file to trash
    [[ -f ${LOC} ]] && mv ${LOC} ~/.Trash
  done < ${CACHE}/YESMO_XML

  echo 'n_to_1 ... done'
}
export -f n_to_1

####### end of functions 

#######      main        #############

kill_all_windows_titled "At first please edit"
init_sys
config				     # source / update config file; reenter thisSCRIPT
[ ! "$PARAM1" ] && intro # on reentry, bypass the intro window.


if [ -f ${WD}/MATCH_TEXTDOMAIN ]; then
#if [ -f ${WD}/MATCH_TD_CHECKED ]; then
  read MATCH_TEXTDOMAIN < ${WD}/MATCH_TEXTDOMAIN
  read CHECKED 2> /dev/null < ${WD}/MATCH_TD_CHECKED
else 
  intro_match  # optional input
fi


fuzzy_use	             # use find_fuzzy 
# building main window
pop_up "Please wait, building cache, scanning files..."
nomo_yesmo	 #always needed gettext'ed (and t12s) scripts ... (and .md files)
[ "$transLANG" = "en" ] || nobin_yesbin #200325 moved here to be also in main window
if [ -z "${MATCH_TEXTDOMAIN}" ]; then #complete main window
    TRANSLANG=""				# unsure why needed, let it continue existing....
    menu_combos_with_HELP
    if [ ! $isFATDOG ]; then
        noxml_yesxml			# XML
        nosss_yessss			# SimpleStringSubstitution	
    fi
    #nobin_yesbin				# mo for binary executables; moved up #200325
    langpack_button							 
fi
kill `pidof popup yaf-splash` 2>/dev/null
main_window # composes MM2_DLG
echo ${MM2_DLG}> /tmp/moma

eval $($GTKDIALOGEXE --program=MM2_DLG)

if [ "$POEDITOR" ];then
    if [ "$POCHECK" = "true" ];then # save choice about use of poeditor
        touch /var/local/poedit_check
    else
        rm -f /var/local/poedit_check 2>/dev/null
        POEDITOR=""
    fi
fi
#
case "$EXIT" in
 edit_mo|create_mo)		edit_create_mo	;;  #duplication eliminated
 preferences)			pref			;;	#modify configuration file
 edit_desk|create_desk)	edit_create_desk;;	#menu entries
 edit_top|create_top)	edit_create_top ;;	#menu categories
 edit_bin|create_bin)	edit_create_bin	;;  #binary executables.
 create_pet)			update_transl   ;;  #create langpack PET
 edit_sss|create_sss)	edit_create_sss ;;	#BK's SSSubstitution method.
 edit_xml|create_xml)	edit_create_xml	;;	#XML data files.
 n_to_1_preview) n_to_1_preview  #preview decrease number of TEXTDOMAINs 
                 LANG=$ORIGLANG exec $thisSCRIPT reenter "MATCH_TEXTDOMAIN=$TD_NEW"
                 ;; 
 n_to_1)    	n_to_1                  #decrease number of TEXTDOMAINs 
				rm $CACHE/*;rm -d $WD/*	#clear cache and start again
                kill_all_windows_titled "At first please edit"
                sync
				LANG=$ORIGLANG exec $thisSCRIPT reenter "MATCH_TEXTDOMAIN=$TD_NEW"
				;;
 refresh)		#clear cache and start again
				rm $CACHE/*;rm -d $WD/*
				kill_all_windows_titled "At first please edit"
				echo -n $CHECKED > ${WD}/MATCH_TD_CHECKED
				LANG=$ORIGLANG exec $thisSCRIPT reenter MATCH_TEXTDOMAIN=$MATCH_TEXTDOMAIN
				;;
 search)		#find searchENTRY in po files
				search_LC_MESSAGES "$searchENTRY" &
				LANG=$ORIGLANG exec $thisSCRIPT reenter "searchENTRY=$searchENTRY"
				;;
 toggle_sort)	#sort messages by msgid/FILE and start again
				sed -i 's/^#SORTby/*SORTby/' $CONFIG
				sed -i 's/^SORTby/#SORTby/'  $CONFIG
                sed -i 's/^*SORTby/SORTby/'  $CONFIG
				LANG=$ORIGLANG exec $thisSCRIPT reenter "sort_messages_by=$sort_messages_by"
				;;
 toggle_yesmo)	#toggle items per script
                # and items per textdomain and start again
				sed -i 's/^#show_scripts/*show_scripts/' $CONFIG
				sed -i 's/^show_scripts/#show_scripts/'  $CONFIG
				sed -i 's/^*show_scripts/show_scripts/'  $CONFIG
				LANG=$ORIGLANG exec $thisSCRIPT reenter "show_scripts=$show_scripts"
				;;
esac

###END###
