momanager 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  1. #!/bin/sh
  2. #(c) Barry Kauler Feb 2012 bkhome.org
  3. #licence GPL3 refer /usr/share/doc/legal
  4. #the intention of this script is to manage non-english translations of files.
  5. #this is to include shell scripts, xml, .desktop and menu files.
  6. #translation will only be for the current language, and UTF-8 must be enabled.
  7. #120205 first release, handle gettext'ed scripts.
  8. #120206 added internationalization management of menu.
  9. #120206 simplify gui with help buttons.
  10. #120206 add management of menu categories.
  11. #120207 write translations to a folder in /root with full path, write.log, generate tarball.
  12. #120208 support SSS domains. (read comments in /usr/share/sss/menu_strings/menu_strings for more info)
  13. #120208 sync translated sss-file with master sss-file.
  14. #120209 desk_strings domain translates target files in-place, so need workaround when edit TRANSLATION variables in desk_strings.*
  15. #120209 ...ditto for script_strings
  16. #120210 add handling XML files.
  17. #120212 some tweaks.
  18. #120213 rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
  19. #120213 added management of binary executables.
  20. #120214 generate a langpack PET package.
  21. #120215 added management of initrd files (initrd_strings SSS domain).
  22. #120217 small message fixes.
  23. #120217 support poeditor.
  24. #120218 LANG=${ORIGLANG} prefix needed various places. 120219 a few more.
  25. #120220 need 'head -n1' ex: /usr/local/petget/ui_Classic has export TEXTDOMAIN in two places.
  26. #120224 add 'doc_strings' sss domain, for translating entire files (typically documentation files). 120225 improvements.
  27. #120225 checkbox window to select what documentation files to edit. modify edit-complete message.
  28. #120228 sync doc_strings sss file.
  29. #120307 ROX-Filer now translated via /usr/share/doc/nls/ROX-Filer/ROX-Filer.pot
  30. #120308 ROX-Filer .mo files are not in standard location. workaround when intltool-update fails.
  31. #120309 binary executables, option to retain po file for later editing (instead of uncompile mo).
  32. #120313 langpack pet help msg improved.
  33. #120313 langpack pet: offer to find more po, mo, pot and t12s translations.
  34. #120316 scoop up more translations. 120317 L18L: add man pages.
  35. #120216 small mod. to a message.
  36. #120729 L18L: problem gettext'ing zigbert's apps, which have a lot of scripts, but would like to combine into one .pot file.
  37. #120731 revert 120729.
  38. #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.
  39. #120731 multiple scripts can have the same TEXTDOMAIN. these scripts can be anywhere. a single .pot will be created/edited.
  40. #120926 want to accumulate many .desktop files (not just for installed pkgs), in /usr/share/applications.in.
  41. #121124 edit script_strings.*, 'read -r' so backslash chars are not escapes.
  42. #130502 L18L/BK: stay in a loop if there is an error converting .po to .mo.
  43. #130503 test if .po file changed. 130506 bug fix.
  44. #130503 L18L: rename AppInfo.xml to AppInfo.xml.in for langpack
  45. #130512 acknowledge new translators.
  46. #130526 L18L: intltool-update fails with ROX-Filer and xdialog, but msgmerge works.
  47. #130807 L18L: need sync.
  48. #***MOMANAGER IS ENGLISH ONLY (NOT GETTEXT'ED)***
  49. #it is for use by developers/translators with knowledge of english.
  50. PARAM1=""
  51. [ $1 ] && PARAM1="$1"
  52. ORIGLANG=$LANG
  53. export LANG=C
  54. . /etc/rc.d/PUPSTATE
  55. GTKDIALOGEXE="gtkdialog"
  56. [ "`which gtkdialog4`" ] && GTKDIALOGEXE="gtkdialog4"
  57. mkdir -p /tmp/momanager
  58. ADATE="`date +%Y%m%d`" #ex: 20120205
  59. WINICON="gtk-preferences"; HELPICON="gtk-index" #gtk-info
  60. ORIGLANG1="`echo -n $ORIGLANG | cut -f 1 -d '_'`" #ex: de
  61. ORIGLANG12="`echo -n $ORIGLANG | cut -f 1 -d '.'`" #ex: de_DE
  62. if [ "$ORIGLANG1" = "en" ];then
  63. 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
  64. exit 1
  65. fi
  66. if [ "`echo -n $ORIGLANG | grep -i 'utf'`" = "" ];then
  67. pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, your \Zblocale\ZB (language) must have UTF-8 enabled to use this application. Click the \Zbsetup\ZB icon on the desktop to change locale. Aborting." 0 0
  68. exit 1
  69. fi
  70. if [ "`which gcc`" = "" ];then
  71. pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, you must have the \Zbdevx\ZB SFS loaded. Aborting." 0 0
  72. exit 1
  73. fi
  74. MISSINGFILE=""
  75. [ "`which intltool-update`" = "" ] && MISSINGFILE="intltool-update "
  76. [ "`which xgettext`" = "" ] && MISSINGFILE="${MISSINGFILE}xgettext "
  77. [ "`which msginit`" = "" ] && MISSINGFILE="${MISSINGFILE}msginit "
  78. [ "`which msgfmt`" = "" ] && MISSINGFILE="${MISSINGFILE}msgfmt "
  79. [ "`which msgunfmt`" = "" ] && MISSINGFILE="${MISSINGFILE}msgunfmt "
  80. [ "`which msgmerge`" = "" ] && MISSINGFILE="${MISSINGFILE}msgmerge" #130526
  81. if [ "$MISSINGFILE" ];then
  82. pupdialog --title "MoManager: abort" --background pink --colors --msgbox "Sorry, these needed applications are missing: \Zb${MISSINGFILE}\ZB. The \Zbdevx\ZB SFS normally has these, but it must be incomplete. Aborting." 0 0
  83. exit 1
  84. fi
  85. POEDITOR="`which poeditor`"
  86. [ ! "$POEDITOR" ] && POEDITOR="`which poedit`"
  87. PATHPREFIX=""
  88. case $PUPMODE in
  89. 2) PATHPREFIX="" ;; #full hd installation.
  90. 3) PATHPREFIX="" ;;
  91. *) PATHPREFIX="/initrd/pup_ro2" ;;
  92. esac
  93. if [ "$PATHPREFIX" = "" ];then
  94. 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
  95. exit 1
  96. fi
  97. ppPTN="s%${PATHPREFIX}%%"
  98. #download woof, to get latest files... no, too difficult, just put up warning...
  99. export MM1_DLG="<window title=\"MoManager: welcome\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
  100. <vbox>
  101. <text><label>Welcome, MoManager will help you to create and edit language translations for your country, for many of the applications in Puppy.</label></text>
  102. <text><label>VERY IMPORTANT: You must be currently running a Puppy built from the latest version of Woof, or very near latest. If your Puppy is even a month old, it is recommended that you check for a later release -- and be sure that it is built from the latest Woof. You can check my blog (bkhome.org/blog2) for release announcements, or adventurous developers can even download Woof and build their own Puppy (the online Woof repository at bkhome.org/fossil/woof2.cgi has link to instructions)</label></text>
  103. <text><label>If you are currently running a very recent Woof-built Puppy, then click the 'OK' button to continue running MoManager:</label></text>
  104. <hbox>
  105. <button ok></button>
  106. <button cancel></button>
  107. </hbox>
  108. </vbox>
  109. </window>
  110. "
  111. if [ ! "$PARAM1" ];then #on reentry, bypass this window.
  112. MM1RET="`$GTKDIALOGEXE --program=MM1_DLG`"
  113. [ "`echo "$MM1RET" | grep 'OK'`" = "" ] && exit 2
  114. fi
  115. /usr/lib/gtkdialog/box_splash -close never -text "Please wait, scanning files..." &
  116. yPID=$!
  117. echo -n "" > /tmp/momanager/translations4langpack #to create the langpack PET.
  118. TRANSLANG=""
  119. poptop_func() {
  120. #passed param $1 is string to display at top of screen, optional $2 is color, $3 is timeout.
  121. BACKCOL='yellow'
  122. [ $2 ] && BACKCOL="$2"
  123. POPTIME='9'
  124. [ $3 ] && POPTIME="$3"
  125. echo "#!/bin/sh
  126. sleep 3
  127. /usr/lib/gtkdialog/box_splash -bg ${BACKCOL} -placement top -timeout ${POPTIME} -text \"${1}\"
  128. " > /tmp/momanager/yafmsg9${POPTIME}
  129. chmod 755 /tmp/momanager/yafmsg9${POPTIME}
  130. /tmp/momanager/yafmsg9${POPTIME} & #msg has delay so will appear on top of text editor window.
  131. }
  132. #####SCRIPTS#######
  133. #find all gettext'ed scripts...
  134. GETTEXTSCRIPTS="`find /bin /sbin /usr/bin /usr/sbin /usr/X11R7/bin /usr/local /etc/rc.d /root/my-applications/bin -maxdepth 4 -type f -executable | xargs -I INPUTFILE grep --files-with-matches '^export TEXTDOMAIN=' INPUTFILE | sed -e 's% %SPACECHAR%g' | sort | tr '\n' ' '`"
  135. #find all matching .mo files...
  136. YESCNT=0; NOCNT=0; YESMO_XML=""; NOMO_XML=""
  137. for AGTS in $GETTEXTSCRIPTS
  138. do
  139. xAGTS="`echo -n $AGTS | sed -e 's%SPACECHAR% %g'`"
  140. #120731 what if code is: export TEXTDOMAIN='abc' or export TEXTDOMAIN="abc" remove the quotes... NO, not allowed to have quotes!!!!
  141. 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.
  142. #want to know if from Woof or a builtin pkg or later-installed pkg...
  143. BASExAGTS="`basename "$xAGTS"`"
  144. xPTN=" ${BASExAGTS}$"
  145. PATHxAGTS="`dirname "$xAGTS"`"
  146. xxPTN="^${PATHxAGTS}$"
  147. zPTN="^${xAGTS}$"
  148. aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
  149. if [ "$aPKGNAME" ];then #confirm full path.
  150. for AAA in $aPKGNAME
  151. do
  152. CONFIRM="`cat /root/.packages/builtin_files/${AAA} | sed -e 's%^ %/%' | tr -d '\n' | grep "$xAGTS"`"
  153. if [ "$CONFIRM" ];then
  154. aPKGNAME="$AAA"
  155. break
  156. fi
  157. done
  158. [ ! "$CONFIRM" ] && aPKGNAME=""
  159. fi
  160. [ ! "$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
  161. #...return nothing if in Woof
  162. [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${xAGTS}" ] && aPKGNAME="WOOF" #file is in Woof.
  163. [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
  164. FNDMO=""
  165. if [ -f /usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
  166. FNDMO="/usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
  167. TRANSLANG=$ORIGLANG12
  168. else
  169. if [ -f /usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
  170. FNDMO="/usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
  171. TRANSLANG=$ORIGLANG1
  172. fi
  173. fi
  174. if [ "$FNDMO" ];then
  175. YESCNT=$(($YESCNT + 1))
  176. YESMO_XML="${YESMO_XML}
  177. <item>${xAGTS} (${TRANSLANG} ${TEXTDOMAINVALUE}.mo ${aPKGNAME})</item>"
  178. echo "$FNDMO" >> /tmp/momanager/translations4langpack
  179. else
  180. NOCNT=$(($NOCNT + 1))
  181. NOMO_XML="${NOMO_XML}
  182. <item>${xAGTS} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>"
  183. fi
  184. done
  185. if [ "$YESMO_XML" ];then
  186. YESMO_XML="<combobox width-request=\"310\"><variable>YESMO_COMBO</variable>${YESMO_XML}</combobox>"
  187. else
  188. YESMO_XML="<combobox width-request=\"310\"><variable>EMPTYYESMO_COMBO</variable><item>--empty--</item></combobox>"
  189. fi
  190. if [ "$NOMO_XML" ];then
  191. NOMO_XML="<combobox width-request=\"330\"><variable>NOMO_COMBO</variable>${NOMO_XML}</combobox>"
  192. else
  193. #NOMO_XML="<text><label>nothing</label></text>"
  194. NOMO_XML="<combobox width-request=\"330\"><variable>EMPTYNOMO_COMBO</variable><item>--empty--</item></combobox>"
  195. fi
  196. #######MENU ENTRIES#######
  197. #find out which .desktop files have [lang] entries already, create two lists...
  198. YESDESK_XML=""; NODESK_XML=""
  199. dPTN="\\[${ORIGLANG1}\\]"
  200. for ADESKTOP in `find /usr/share/applications -mindepth 1 -maxdepth 1 -type f -name '*.desktop' | grep -v ' ' | sort | tr '\n' ' '`
  201. do
  202. [ "`grep '^Icon' $ADESKTOP`" = "" ] && continue #some dummy .desktop files used by xfce, ignore them.
  203. ADESKNAME="`basename $ADESKTOP`"
  204. #find out what package it is from...
  205. xPTN=" ${ADESKNAME}$"
  206. zPTN="^${ADESKTOP}$"
  207. aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | head -n 1 | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
  208. [ ! "$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
  209. #...return nothing if in Woof
  210. [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${ADESKTOP}" ] && aPKGNAME="WOOF" #file is in Woof.
  211. [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
  212. if [ "`grep "$dPTN" $ADESKTOP`" != "" ];then
  213. YESDESK_XML="${YESDESK_XML}
  214. <item>${ADESKNAME} (${aPKGNAME})</item>"
  215. echo "$ADESKTOP" >> /tmp/momanager/translations4langpack
  216. else
  217. NODESK_XML="${NODESK_XML}
  218. <item>${ADESKNAME} (${aPKGNAME})</item>"
  219. fi
  220. done
  221. if [ "$YESDESK_XML" ];then
  222. YESDESK_XML="<combobox width-request=\"310\"><variable>YESDESK_COMBO</variable>${YESDESK_XML}</combobox>"
  223. else
  224. YESDESK_XML="<combobox width-request=\"310\"><variable>EMPTYYESDESK_COMBO</variable><item>--empty--</item></combobox>"
  225. fi
  226. if [ "$NODESK_XML" ];then
  227. NODESK_XML="<combobox width-request=\"330\"><variable>NODESK_COMBO</variable>${NODESK_XML}</combobox>"
  228. else
  229. NODESK_XML="<combobox width-request=\"330\"><variable>EMPTYNODESK_COMBO</variable><item>--empty--</item></combobox>"
  230. fi
  231. #help buttons...
  232. YESMO_HELP_MSG="Puppy has many <b>scripts</b>, applications that are plain text files, usually written in Bash or Ash. These scripts all have English capability, but language translation files may be created for them, known as <b>mo</b> files.
  233. The drop-down list is a list of scripts for which there is a mo translation file in your language.
  234. 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.
  235. A mo translation file in your language (${ORIGLANG12}) is at /usr/share/locale/${ORIGLANG12}/LC_MESSAGES/ or /usr/share/locale/${ORIGLANG1}/LC_MESSAGES/. You may select one of the scripts, then click the <b>Edit</b> button to update it.
  236. 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."
  237. export DLG_HELP_YESMO="<window resizable=\"false\" title=\"MoManager: Help edit mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESMO_HELP_MSG}\"</label><variable>VAR_HELP_YESMO</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESMO</action></button></hbox></vbox></window>"
  238. YESMOHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESMO</action></button>'
  239. NOMO_HELP_MSG="Puppy has many <b>scripts</b>, applications that are plain text files, usually written in Bash or Ash. These scripts all have English capability, but language translation files may be created for them, known as <b>mo</b> files.
  240. The drop-down list is a list of scripts for which there is no mo translation file in your language.
  241. 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.
  242. 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."
  243. export DLG_HELP_NOMO="<window resizable=\"false\" title=\"MoManager: Help create mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NOMO_HELP_MSG}\"</label><variable>VAR_HELP_NOMO</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOMO</action></button></hbox></vbox></window>"
  244. NOMOHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOMO</action></button>'
  245. YESDESK_HELP_MSG="The drop-down list is of .desktop files in /usr/share/applications, that have translations for your language.
  246. 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.
  247. If you need to correct an entry, select the appropriate .desktop file, then click the <b>Edit</b> button.
  248. 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."
  249. 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>"
  250. YESDESKHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESDESK</action></button>'
  251. 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.
  252. 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.
  253. If you wish to create a translation, select the appropriate .desktop file, then click the <b>Create</b> button.
  254. 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."
  255. 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>"
  256. NODESKHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NODESK</action></button>'
  257. #######MENU TITLES#######
  258. #this gives us the list of .directory files in /usr/share/desktop-directories for the top-level titles... ex: Puppy-Setup.directory
  259. TOPMENUFILES="`grep -m1 '<Directory>' /etc/xdg/menus/puppy-[^S]*.menu | cut -f 2 -d '>' | cut -f 1 -d '<' | grep 'directory$' | sort | tr '\n' ' '`"
  260. YESTOP_XML=""; NOTOP_XML=""
  261. dPTN="^Name\\[${ORIGLANG1}\\]"
  262. for ATOPMENUFILE in $TOPMENUFILES
  263. do
  264. if [ "`grep "$dPTN" /usr/share/desktop-directories/$ATOPMENUFILE`" != "" ];then
  265. #there is already a translation.
  266. YESTOP_XML="${YESTOP_XML}
  267. <item>${ATOPMENUFILE}</item>"
  268. echo "/usr/share/desktop-directories/${ATOPMENUFILE}" >> /tmp/momanager/translations4langpack
  269. else
  270. NOTOP_XML="${NOTOP_XML}
  271. <item>${ATOPMENUFILE}</item>"
  272. fi
  273. done
  274. if [ "$YESTOP_XML" ];then
  275. YESTOP_XML="<combobox width-request=\"310\"><variable>YESTOP_COMBO</variable>${YESTOP_XML}</combobox>"
  276. else
  277. YESTOP_XML="<combobox width-request=\"310\"><variable>EMPTYYESTOP_COMBO</variable><item>--empty--</item></combobox>"
  278. fi
  279. if [ "$NOTOP_XML" ];then
  280. NOTOP_XML="<combobox width-request=\"330\"><variable>NOTOP_COMBO</variable>${NOTOP_XML}</combobox>"
  281. else
  282. NOTOP_XML="<combobox width-request=\"330\"><variable>EMPTYNOTOP_COMBO</variable><item>--empty--</item></combobox>"
  283. fi
  284. #help buttons...
  285. 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.
  286. 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."
  287. 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>"
  288. YESTOPHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESTOP</action></button>'
  289. 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).
  290. 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."
  291. 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>"
  292. NOTOPHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOTOP</action></button>'
  293. #######XML#######
  294. #search $PATHPREFIX to avoid devx files...
  295. YESXML_XML='' ; NOXML_XML=''
  296. XMLFILES="`find /usr/local -type f -name '*.xml' | sed -e 's% %SPACECHAR%g' | tr '\n' ' '`" #ex: /usr/local/apps/Connect/AppInfo.xml
  297. aPTN="xml:lang=\"${ORIGLANG1}\"" #ex: xml:lang="de"
  298. bPTN="xml:lang=\"${ORIGLANG12}\"" #ex: xml:lang="de_DE"
  299. for AXMLFILE in $XMLFILES
  300. do
  301. AXMLFILE="`echo -n "$AXMLFILE" | sed -e 's%SPACECHAR% %g'`"
  302. #want to know if from Woof or a builtin pkg or later-installed pkg...
  303. BASEAXMLFILE="`basename "$AXMLFILE"`"
  304. xPTN=" ${BASEAXMLFILE}$"
  305. PATHAXMLFILE="`dirname "$AXMLFILE"`"
  306. xxPTN="^${PATHAXMLFILE}$"
  307. zPTN="^${AXMLFILE}$"
  308. aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
  309. if [ "$aPKGNAME" ];then #confirm full path.
  310. for AAA in $aPKGNAME
  311. do
  312. CONFIRM="`cat /root/.packages/builtin_files/${AAA} | sed -e 's%^ %/%' | tr -d '\n' | grep "$AXMLFILE"`"
  313. if [ "$CONFIRM" ];then
  314. aPKGNAME="$AAA"
  315. break
  316. fi
  317. done
  318. [ ! "$CONFIRM" ] && aPKGNAME=""
  319. fi
  320. [ ! "$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
  321. #...return nothing if in Woof
  322. [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${AXMLFILE}" ] && aPKGNAME="WOOF" #file is in Woof.
  323. [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
  324. FNDFLAG=''
  325. FNDFLAG="`grep "$aPTN" "$AXMLFILE"`"
  326. [ ! "$FNDFLAG" ] && FNDFLAG="`grep "$bPTN" "$AXMLFILE"`"
  327. if [ "$FNDFLAG" ];then
  328. #there is already a translation.
  329. YESXML_XML="${YESXML_XML}
  330. <item>${AXMLFILE} (${aPKGNAME})</item>"
  331. echo "${AXMLFILE}" >> /tmp/momanager/translations4langpack
  332. else
  333. NOXML_XML="${NOXML_XML}
  334. <item>${AXMLFILE} (${aPKGNAME})</item>"
  335. fi
  336. done
  337. if [ "$YESXML_XML" ];then
  338. YESXML_XML="<combobox width-request=\"310\"><variable>YESXML_COMBO</variable>${YESXML_XML}</combobox>"
  339. else
  340. YESXML_XML="<combobox width-request=\"310\"><variable>EMPTYYESXML_COMBO</variable><item>--empty--</item></combobox>"
  341. fi
  342. if [ "$NOXML_XML" ];then
  343. NOXML_XML="<combobox width-request=\"330\"><variable>NOXML_COMBO</variable>${NOXML_XML}</combobox>"
  344. else
  345. NOXML_XML="<combobox width-request=\"330\"><variable>EMPTYNOXML_COMBO</variable><item>--empty--</item></combobox>"
  346. fi
  347. #help buttons...
  348. 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:
  349. &lt;Label&gt;Connect to the Internet now&lt;/Label&gt;
  350. &lt;Label xml:lang="ru"&gt;Подключиться к Интернет сейчас&lt;/Label&gt;
  351. &lt;Label xml:lang="ja"&gt;インターネット接続ウィザードを実行&lt;/Label&gt;
  352. &lt;Label xml:lang="zh_CN"&gt;运行互联网连接向导&lt;/Label&gt;"
  353. YESXML_HELP_MSG="${XML_COM_HELP}
  354. 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.
  355. 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."
  356. 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>"
  357. YESXMLHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESXML</action></button>'
  358. NOXML_HELP_MSG="${XML_COM_HELP}
  359. 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.
  360. 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."
  361. 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>"
  362. NOXMLHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOXML</action></button>'
  363. #######SSS#######
  364. #Simple String Substitution
  365. #manage translations in many non-executable data files.
  366. #translations are kept in /usr/share/sss/$SSSDOMAIN/$SSSDOMAIN.$ORIGLANG1 ex: SSSDOMAIN=menu_strings ORIGLANG1=de
  367. YESSSS_XML=""; NOSSS_XML=""
  368. for ASSSDOMAIN in `find /usr/share/sss -mindepth 1 -maxdepth 1 -type d | sed -e 's%^/usr/share/sss/%%' | tr '\n' ' '`
  369. do
  370. #120224 doc_strings is a special case, the translated file is elsewhere...
  371. if [ -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} ];then
  372. if [ "$ASSSDOMAIN" = "doc_strings" ];then
  373. cp -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN} /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} #120228 must always be same as orig.
  374. TRANSFLAG='fail'
  375. TRANSLATEDFILES="`grep '^SSS_TRANSLATION_RULE' /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} | cut -f 2 -d "'" | sed -e "s%SSSLANG1MARKER%${ORIGLANG1}%" | tr '\n' ' '`" #'geanyfix
  376. for ATRANSLATEDFILE in $TRANSLATEDFILES
  377. do
  378. if [ -f $ATRANSLATEDFILE ];then
  379. echo "$ATRANSLATEDFILE" >> /tmp/momanager/translations4langpack
  380. TRANSFLAG='success'
  381. fi
  382. done
  383. [ "$TRANSFLAG" = "fail" ] && rm -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} #because translated file(s) does not exist.
  384. fi
  385. fi
  386. if [ -f /usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1} ];then
  387. #there is already a translation.
  388. YESSSS_XML="${YESSSS_XML}
  389. <item>${ASSSDOMAIN}.${ORIGLANG1}</item>"
  390. echo "/usr/share/sss/${ASSSDOMAIN}/${ASSSDOMAIN}.${ORIGLANG1}" >> /tmp/momanager/translations4langpack
  391. else
  392. NOSSS_XML="${NOSSS_XML}
  393. <item>${ASSSDOMAIN}</item>"
  394. fi
  395. done
  396. if [ "$YESSSS_XML" ];then
  397. YESSSS_XML="<combobox width-request=\"310\"><variable>YESSSS_COMBO</variable>${YESSSS_XML}</combobox>"
  398. else
  399. YESSSS_XML="<combobox width-request=\"310\"><variable>EMPTYYESSSS_COMBO</variable><item>--empty--</item></combobox>"
  400. fi
  401. if [ "$NOSSS_XML" ];then
  402. NOSSS_XML="<combobox width-request=\"330\"><variable>NOSSS_COMBO</variable>${NOSSS_XML}</combobox>"
  403. else
  404. NOSSS_XML="<combobox width-request=\"330\"><variable>EMPTYNOSSS_COMBO</variable><item>--empty--</item></combobox>"
  405. fi
  406. #help buttons...
  407. SSS_DOMAINS_MSG="
  408. <b>menu_strings</b>
  409. 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).
  410. <b>desk_strings</b>
  411. These are translations for any text data-files that have some text that displays on-screen.
  412. <b>script_strings</b>
  413. 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).
  414. <b>initrd_strings</b>
  415. These are translations for files in the initrd (also known as the initramfs). This is a bit different from the other SSS domains, as the target files are translated at bootup, every bootup.
  416. <b>doc_strings</b>
  417. This is totally different from all the above, as translations are made of entire files, using a suitable editor -- this is typically documentation files."
  418. 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:
  419. ${SSS_DOMAINS_MSG}"
  420. 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>"
  421. YESSSSHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESSSS</action></button>'
  422. 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:
  423. ${SSS_DOMAINS_MSG}"
  424. 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>"
  425. NOSSSHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOSSS</action></button>'
  426. ########Binary executables#######
  427. #support a limited number of binary executables that have .pot files in /usr/share/doc/nls
  428. YESCNT=0 ; NOCNT=0 ; YESBIN_XML="" ; NOBIN_XML=""
  429. for ANLSDIR in `ls -1 /usr/share/doc/nls | tr '\n' ' '`
  430. do
  431. if [ -d /usr/share/doc/nls/${ANLSDIR} ];then
  432. #120309 po files may now be there... ex: /usr/share/doc/nls/ROX-Filer/de.po
  433. FNDPO="`find /usr/share/doc/nls/${ANLSDIR} -mindepth 1 -maxdepth 1 -type f -name '*.po' | tr '\n' ' '`"
  434. for APO in $FNDPO
  435. do
  436. echo "$APO" >> /tmp/momanager/translations4langpack
  437. done
  438. BINEXEC=""
  439. BINEXEC="`which $ANLSDIR`"
  440. [ ! "$BINEXEC" ] && BINEXEC="`find /usr/local -maxdepth 4 -executable -type f -name "$ANLSDIR"`" #ex: /usr/local/simple_network_setup/proxy-setup
  441. if [ "$BINEXEC" ];then
  442. if [ "`file "$BINEXEC" | grep ' ELF ' | grep 'LSB executable'`" != "" ];then
  443. #have found binary executable for the pot file...
  444. TEXTDOMAINVALUE="$ANLSDIR" #TEXTDOMAIN must be same as executable name.
  445. #want to know if from Woof or a builtin pkg or later-installed pkg...
  446. BASEBINEXEC="`basename "$BINEXEC"`"
  447. xPTN=" ${BASEBINEXEC}$"
  448. PATHBINEXEC="`dirname "$BINEXEC"`"
  449. xxPTN="^${PATHBINEXEC}$"
  450. zPTN="^${BINEXEC}$"
  451. aPKGNAME="`grep "$xPTN" /root/.packages/builtin_files/* | cut -f 1 -d ':' | rev | cut -f 1 -d '/' | rev`" #test if pkg used in Woof build.
  452. if [ "$aPKGNAME" ];then #confirm full path.
  453. for AAA in $aPKGNAME
  454. do
  455. CONFIRM="`cat /root/.packages/builtin_files/${AAA} | sed -e 's%^ %/%' | tr -d '\n' | grep "$BINEXEC"`"
  456. if [ "$CONFIRM" ];then
  457. aPKGNAME="$AAA"
  458. break
  459. fi
  460. done
  461. [ ! "$CONFIRM" ] && aPKGNAME=""
  462. fi
  463. [ ! "$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
  464. #...return nothing if in Woof
  465. [ ! "$aPKGNAME" ] && [ -f "${PATHPREFIX}${BINEXEC}" ] && aPKGNAME="WOOF" #file is in Woof.
  466. [ ! "$aPKGNAME" ] && aPKGNAME="UNKNOWN"
  467. FNDMO=""
  468. PREFIXLOCALEDIR='/usr/share/locale' #120308
  469. if [ -f /usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
  470. FNDMO="/usr/share/locale/${ORIGLANG12}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
  471. TRANSLANG=$ORIGLANG12
  472. else
  473. if [ -f /usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo ];then
  474. FNDMO="/usr/share/locale/${ORIGLANG1}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo"
  475. TRANSLANG=$ORIGLANG1
  476. fi
  477. fi
  478. #120308 ROX-Filer is example where .mo is elsewhere. search all roxapps..
  479. if [ ! "$FNDMO" ];then
  480. FNDMO="`find /usr/local/apps -type f -name "${TEXTDOMAINVALUE}.mo"`"
  481. TRANSLANG=$ORIGLANG1
  482. 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
  483. fi
  484. if [ "$FNDMO" ];then
  485. YESCNT=$(($YESCNT + 1))
  486. YESBIN_XML="${YESBIN_XML}
  487. <item>${BINEXEC} (${TRANSLANG} ${TEXTDOMAINVALUE}.mo ${aPKGNAME})</item>"
  488. echo "${PREFIXLOCALEDIR}/${TRANSLANG}/LC_MESSAGES/${TEXTDOMAINVALUE}.mo" >> /tmp/momanager/translations4langpack #120308
  489. else
  490. NOCNT=$(($NOCNT + 1))
  491. NOBIN_XML="${NOBIN_XML}
  492. <item>${BINEXEC} (${TEXTDOMAINVALUE} ${aPKGNAME})</item>"
  493. fi
  494. fi
  495. fi
  496. fi
  497. done
  498. if [ "$YESBIN_XML" ];then
  499. YESBIN_XML="<combobox width-request=\"310\"><variable>YESBIN_COMBO</variable>${YESBIN_XML}</combobox>"
  500. else
  501. YESBIN_XML="<combobox width-request=\"310\"><variable>EMPTYYESBIN_COMBO</variable><item>--empty--</item></combobox>"
  502. fi
  503. if [ "$NOBIN_XML" ];then
  504. NOBIN_XML="<combobox width-request=\"330\"><variable>NOBIN_COMBO</variable>${NOBIN_XML}</combobox>"
  505. else
  506. NOBIN_XML="<combobox width-request=\"330\"><variable>EMPTYNOBIN_COMBO</variable><item>--empty--</item></combobox>"
  507. fi
  508. #help buttons...
  509. YESBIN_HELP_MSG="MoManager provides translation support for a limited number of binary executables. These are executables in Woof or in PET packages, that have <b>pot</b> files at /usr/share/doc/nls. The drop-down list is of binary executables that already have a ${ORIGLANG1} or ${ORIGLANG12} translation, but you may wish to review the translations, especially if the version of the binary executable has changed. Select a file, then click the <b>Edit</b> button.
  510. 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.
  511. A <b>pot</b> file is a translation template file. MoManager converts it to a <b>po</b> file, which is an editable form for your language, and it is finally compiled to a <b>mo</b> file and placed at /usr/share/locale.
  512. There are many other binary executable applications in Puppy that are not managed by MoManager. For those, for example the Abiword word processor, the author of the application provides translations. In many cases you can find a nls translation package for an application via the Puppy Package Manager."
  513. export DLG_HELP_YESBIN="<window resizable=\"false\" title=\"MoManager: Help edit mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${YESBIN_HELP_MSG}\"</label><variable>VAR_HELP_YESBIN</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_YESBIN</action></button></hbox></vbox></window>"
  514. YESBINHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_YESBIN</action></button>'
  515. NOBIN_HELP_MSG="MoManager provides translation support for a limited number of binary executables. These are executables in Woof or in PET packages, that have <b>pot</b> files at /usr/share/doc/nls. The drop-down list is of binary executables that do <i>not</i> have a ${ORIGLANG1} or ${ORIGLANG12} translation. To create one, select a file, then click the <b>Create</b> button.
  516. 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.
  517. A <b>pot</b> file is a translation template file. MoManager converts it to a <b>po</b> file, which is an editable form for your language, and it is finally compiled to a <b>mo</b> file and placed at /usr/share/locale.
  518. There are many other binary executable applications in Puppy that are not managed by MoManager. For those, for example the Abiword word processor, the author of the application provides translations. In many cases you can find a nls translation package for an application via the Puppy Package Manager."
  519. export DLG_HELP_NOBIN="<window resizable=\"false\" title=\"MoManager: Help create mo files\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${NOBIN_HELP_MSG}\"</label><variable>VAR_HELP_NOBIN</variable></text><hbox><button><label>Close</label><action type=\"closewindow\">VAR_HELP_NOBIN</action></button></hbox></vbox></window>"
  520. NOBINHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_NOBIN</action></button>'
  521. ######langpack PET#####
  522. #help button for PET langpack...
  523. GENLANG="$ORIGLANG1"
  524. [ "$TRANSLANG" ] && GENLANG="$TRANSLANG"
  525. 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.
  526. 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.
  527. 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>.
  528. 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:
  529. Danish (da): maans
  530. German (de): L18L
  531. Greek (el): kounelii
  532. French (fr): esmourguit
  533. Italian (it): vicmz (temporary)
  534. Dutch (nl): Bert
  535. Polish (pl): robwoj44
  536. Portuguese (pt): vicmz
  537. Russian (ru): rodin.s
  538. Spanish (es): vicmz"
  539. 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>"
  540. PETHELP_XML='<button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type="launch">DLG_HELP_PET</action></button>'
  541. POEDIT_XML=""; POEDIT_CHECK='false'
  542. if [ "$POEDITOR" ];then
  543. [ -e /var/local/poedit_check ] && POEDIT_CHECK='true'
  544. POEDIT_XML="<checkbox><label>Tick to use poedit (instead of text editor)</label><default>${POEDIT_CHECK}</default><variable>POCHECK</variable></checkbox> <text><label>\" \"</label></text>"
  545. fi
  546. export MM2_DLG="<window title=\"MoManager: Puppy files\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
  547. <vbox>
  548. <text use-markup=\"true\" width-chars=\"86\"><label>\"<big>Welcome! To fully translate Puppy to your <b>${ORIGLANG12}</b> locale, you need to get all of the files on the right-side drop-down lists over to the left-side lists. Simple! Click the help buttons for explanation about each list...</big>\"</label></text>
  549. <frame Scripts>
  550. <hbox>
  551. <vbox>
  552. <frame Scripts that have a mo file>
  553. <hbox>${YESMO_XML}<button><label>Edit</label><action>EXIT:edit_mo</action></button>${YESMOHELP_XML}</hbox>
  554. </frame>
  555. </vbox>
  556. <vbox>
  557. <frame Scripts that do not have a mo file>
  558. <hbox>${NOMO_XML}<button><label>Create</label><action>EXIT:create_mo</action></button>${NOMOHELP_XML}</hbox>
  559. </frame>
  560. </vbox>
  561. </hbox>
  562. </frame>
  563. <frame Menu categories>
  564. <hbox>
  565. <vbox>
  566. <frame Menu categories with a ${ORIGLANG1} translation>
  567. <hbox>${YESTOP_XML}<button><label>Edit</label><action>EXIT:edit_top</action></button>${YESTOPHELP_XML}</hbox>
  568. </frame>
  569. </vbox>
  570. <vbox>
  571. <frame Menu categories without a ${ORIGLANG1} translation>
  572. <hbox>${NOTOP_XML}<button><label>Create</label><action>EXIT:create_top</action></button>${NOTOPHELP_XML}</hbox>
  573. </frame>
  574. </vbox>
  575. </hbox>
  576. </frame>
  577. <frame Menu entries>
  578. <hbox>
  579. <vbox>
  580. <frame Menu entries with a ${ORIGLANG1} translation>
  581. <hbox>${YESDESK_XML}<button><label>Edit</label><action>EXIT:edit_desk</action></button>${YESDESKHELP_XML}</hbox>
  582. </frame>
  583. </vbox>
  584. <vbox>
  585. <frame Menu entries without a ${ORIGLANG1} translation>
  586. <hbox>${NODESK_XML}<button><label>Create</label><action>EXIT:create_desk</action></button>${NODESKHELP_XML}</hbox>
  587. </frame>
  588. </vbox>
  589. </hbox>
  590. </frame>
  591. <frame XML files>
  592. <hbox>
  593. <vbox>
  594. <frame XML files with a ${ORIGLANG1} translation>
  595. <hbox>${YESXML_XML}<button><label>Edit</label><action>EXIT:edit_xml</action></button>${YESXMLHELP_XML}</hbox>
  596. </frame>
  597. </vbox>
  598. <vbox>
  599. <frame XML files without a ${ORIGLANG1} translation>
  600. <hbox>${NOXML_XML}<button><label>Create</label><action>EXIT:create_xml</action></button>${NOXMLHELP_XML}</hbox>
  601. </frame>
  602. </vbox>
  603. </hbox>
  604. </frame>
  605. <frame SSS domains>
  606. <hbox>
  607. <vbox>
  608. <frame SSS domains with a ${ORIGLANG1} translation>
  609. <hbox>${YESSSS_XML}<button><label>Edit</label><action>EXIT:edit_sss</action></button>${YESSSSHELP_XML}</hbox>
  610. </frame>
  611. </vbox>
  612. <vbox>
  613. <frame SSS domains without a ${ORIGLANG1} translation>
  614. <hbox>${NOSSS_XML}<button><label>Create</label><action>EXIT:create_sss</action></button>${NOSSSHELP_XML}</hbox>
  615. </frame>
  616. </vbox>
  617. </hbox>
  618. </frame>
  619. <frame Binary executables>
  620. <hbox>
  621. <vbox>
  622. <frame Binary executables that have a mo file>
  623. <hbox>${YESBIN_XML}<button><label>Edit</label><action>EXIT:edit_bin</action></button>${YESBINHELP_XML}</hbox>
  624. </frame>
  625. </vbox>
  626. <vbox>
  627. <frame Binary executables that do not have a mo file>
  628. <hbox>${NOBIN_XML}<button><label>Create</label><action>EXIT:create_bin</action></button>${NOBINHELP_XML}</hbox>
  629. </frame>
  630. </vbox>
  631. </hbox>
  632. </frame>
  633. <hbox>
  634. ${POEDIT_XML}
  635. <text><label>Create a langpack PET:</label></text>
  636. <button><input file>/usr/local/lib/X11/mini-icons/pet16.xpm</input><action>EXIT:create_pet</action></button>
  637. ${PETHELP_XML}
  638. <text><label>\" \"</label></text>
  639. <button><label>About</label><action>pupdialog --background '#8080FF' --backtitle 'MoManager: About' --msgbox 'Created by Barry Kauler for Puppy Linux. (c) Copyright Barry Kauler 2012, license GPL3 (refer /usr/share/doc/legal)' 0 0 & </action></button>
  640. <button><label>Exit</label><action>EXIT:quit</action></button>
  641. </hbox>
  642. </vbox>
  643. </window>
  644. "
  645. #echo "$MM2_DLG" > /tmp/xxx #TEST
  646. kill $yPID
  647. MM1RET="`$GTKDIALOGEXE --program=MM2_DLG`"
  648. eval "$MM1RET"
  649. if [ "$POEDITOR" ];then
  650. if [ "$POCHECK" = "true" ];then
  651. touch /var/local/poedit_check
  652. else
  653. rm -f /var/local/poedit_check 2>/dev/null
  654. POEDITOR=""
  655. fi
  656. fi
  657. tarball_func() {
  658. TARBALLMSG="Translation files that you have created with MoManager have been copied into folder \Zb/root/MoManager-${ORIGLANG12}-${APKGNAME}\ZB, and a tarball has been created, \Zb/root/MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz\ZB. Note, it contains \Zbwrite.log\ZB which records the details of each translation file.
  659. 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:
  660. \Zbda\ZB maans
  661. \Zbde\ZB L18L
  662. \Zbel\ZB kounelii
  663. \Zbes\ZB vicmz
  664. \Zbfr\ZB esmourguit
  665. \Zbit\ZB vicmz (temporary)
  666. \Zbnl\ZB Bert
  667. \Zbpl\ZB robwoj44
  668. \Zbpt\ZB vicmz
  669. \Zbru\ZB rodin.s
  670. ...these people can be contacted via the Puppy Linux Forum.
  671. If there is no maintainer for a langpack for \Zb${ORIGLANG1}\ZB, then the invitation is extended to volunteer. You will notice the \ZbPET\ZB button on the main window -- a very easy way to create a PET package of all of the translations. Maintainers may also throw in any other relevant translations that they can find, even dictionary files, but not any binary executables as the PET has to be architecture-independent. When you have it working nicely, send it to me \ZbBarryK\ZB via the Puppy Forum."
  672. pupdialog --background green --colors --backtitle "MoManager: edit completed" --msgbox "${TARBALLMSG}" 0 0
  673. }
  674. #note: edit_mo and create_mo have much common code, *to do* eliminate duplication.
  675. case $EXIT in
  676. edit_mo)
  677. #ex: YESMO_COMBO='/usr/sbin/mousecheck (de mousecheck.mo)'
  678. ASCRIPT="`echo -n "$YESMO_COMBO" | cut -f 1 -d '(' | rev | cut -f 2-9 -d ' ' | rev`"
  679. ANAME="`basename "$ASCRIPT"`"
  680. ATRANSLANG="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`" #ex: de
  681. AMO="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: mousecheck.mo
  682. APKGNAME="`echo -n "$YESMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 3 -d ' '`" #ex: bluefish ex: WOOF
  683. AMOSPEC="/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  684. ATEXTDOMAIN="`basename $AMO .mo`"
  685. cp -f "$AMOSPEC" /tmp/momanager/${ATEXTDOMAIN}.moOLD
  686. msgunfmt "$AMOSPEC" > /tmp/momanager/${ATEXTDOMAIN}1.po
  687. cd /tmp/momanager
  688. case $ATEXTDOMAIN in
  689. alsaconf)
  690. #rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
  691. cp -f /usr/share/doc/nls/alsaconf/alsaconf.pot ./
  692. ;;
  693. *)
  694. #120731 why not generalize the above. any script(s) can have a pre-existing .pot file and it will be used...
  695. if [ -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ];then
  696. cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ./
  697. else
  698. #120731 multiple scripts may have the same TEXTDOMAIN...
  699. tdPTN="^export TEXTDOMAIN=${ATEXTDOMAIN}"
  700. EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "${tdPTN}" INPUTFILE | sed -e 's%SPACECHAR% %g')"
  701. if [ "$EXTRASCRIPTS" ];then
  702. echo -n "" > ./xEXTRASCRIPTS
  703. echo "$EXTRASCRIPTS" |
  704. while read ONEEXTRA
  705. do
  706. [ "$ONEEXTRA" = "" ] && continue
  707. [ ! -f "$ONEEXTRA" ] && continue #precaution.
  708. ONEBASE="$(basename "${ONEEXTRA}" .sh)"
  709. cp -f "$ONEEXTRA" ./${ONEBASE}.sh
  710. echo "${ONEBASE}.sh" >> ./xEXTRASCRIPTS
  711. done
  712. LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap `cat ./xEXTRASCRIPTS`
  713. fi
  714. fi
  715. ;;
  716. esac
  717. #this syncs textdomain1.po and textdomain.pot, merges to textdomain.po ...
  718. rm -f ${ATEXTDOMAIN}.po 2>/dev/null
  719. #130526 L18L: intltool-update fails with ROX-Filer and xdialog, but msgmerge works...
  720. #LANG=${ORIGLANG} rxvt -e intltool-update --dist --gettext-package=${ATEXTDOMAIN} --output-file=${ATEXTDOMAIN}.po ${ATEXTDOMAIN}1
  721. LANG=${ORIGLANG} rxvt -e msgmerge ${ATEXTDOMAIN}1.po ${ATEXTDOMAIN}.pot --output-file=${ATEXTDOMAIN}.po ; #130526 L18L
  722. BINMSG="The .mo file has been converted to an editable .po file. Edit, then Save, then Quit text editor..."
  723. ROPID=0 ; POPCOL='yellow'
  724. #120308 intltool-update is broken with some pot files. need a fallback method...
  725. if [ ! -s ${ATEXTDOMAIN}.po ];then
  726. LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot #create po file without any translations.
  727. LANG=${ORIGLANG} defaulttextviewer /tmp/momanager/${ATEXTDOMAIN}1.po & #warning, this must be different from defaulttexteditor!
  728. ROPID=$!
  729. BINMSG="BAD NEWS: the 'msgmerge' utility was unable to merge your existing translations with the pot file. Therefore, the translations are open in a separate file '${ATEXTDOMAIN}1.po' and you must paste them into '${ATEXTDOMAIN}.po' -- edit the latter only! Edit '${ATEXTDOMAIN}.po', save, then quit..."
  730. POPCOL='LightPink'
  731. fi
  732. poptop_func "$BINMSG" $POPCOL
  733. #130502 L18L/BK: stay in a loop if there is an error converting .po to .mo...
  734. ABORTFLG=0
  735. cp -f /tmp/momanager/${ATEXTDOMAIN}.po /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1
  736. while true ; do
  737. if [ "$POEDITOR" ];then
  738. LANG=${ORIGLANG} ${POEDITOR} /tmp/momanager/${ATEXTDOMAIN}.po
  739. else
  740. killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
  741. sleep 0.5
  742. LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po
  743. fi
  744. if diff -q /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>&1; then #130503 130506
  745. ABORTFLG=8
  746. break
  747. fi
  748. LANG=${ORIGLANG} msgfmt --output-file=- /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>/tmp/momanager/po-2-mo.err
  749. [ ! -s /tmp/momanager/po-2-mo.err ] && break
  750. 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:
  751. `cat /tmp/momanager/po-2-mo.err`
  752. NOTE: The above error message is logged to /tmp/momanager/po-2-mo.err
  753. Click the 'Fix' button to edit the .po file again...
  754. Click 'Revert' to go back to original .po file, and try again...
  755. Click 'Abort' to give up..." 0 0
  756. case $? in
  757. 0) continue ;; #Fix
  758. 3) cp -f /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po ; continue ;; #Revert
  759. *) ABORTFLG=9 ; break ;; #1=Abort
  760. esac
  761. done
  762. [ $ROPID -ne 0 ] && kill $ROPID
  763. if [ $ABORTFLG -eq 0 ];then #130502
  764. LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=/tmp/momanager/${ATEXTDOMAIN}.mo /tmp/momanager/${ATEXTDOMAIN}.po
  765. pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB. Note, as a precaution, the old mo file is at /tmp/momanager/${ATEXTDOMAIN}.moOLD." 0 0
  766. ABORTFLG=$?
  767. fi
  768. if [ $ABORTFLG -eq 0 ];then #130502
  769. cp -f /tmp/momanager/${ATEXTDOMAIN}.mo "${AMOSPEC}"
  770. #output as a tarball that user can email to pkg author...
  771. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES
  772. cp -f /tmp/momanager/${ATEXTDOMAIN}.mo /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/
  773. ASTAT="`stat --format=%y "$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  774. [ -f ${PATHPREFIX}${ASCRIPT} ] && ASTAT="`stat --format=%y "${PATHPREFIX}$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  775. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_SCRIPT=${ASTAT} SCRIPT='${ASCRIPT}' MO_FILE='${AMOSPEC}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  776. cd /root
  777. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  778. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  779. tarball_func
  780. else
  781. 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
  782. fi
  783. export LANG=$ORIGLANG
  784. exec momanager reenter
  785. ;;
  786. create_mo)
  787. #ex: NOMO_COMBO='/usr/sbin/mousecheck (mousecheck)'
  788. ASCRIPT="`echo -n "$NOMO_COMBO" | cut -f 1 -d '(' | rev | cut -f 2 -d ' ' | rev`"
  789. ATEXTDOMAIN="`echo -n "$NOMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`"
  790. APKGNAME="`echo -n "$NOMO_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: bluefish ex: WOOFBUILTIN
  791. FIELD2ND="`echo -n "$ORIGLANG12" | cut -f 2 -d '_'`"
  792. 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
  793. if [ $? -eq 0 ];then
  794. ATRANSLANG="$ORIGLANG1"
  795. else
  796. ATRANSLANG="$ORIGLANG12"
  797. fi
  798. ANAME="`basename "$ASCRIPT"`"
  799. AMO="${ATEXTDOMAIN}.mo"
  800. AMOSPEC="/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  801. mkdir -p /usr/share/locale/${ATRANSLANG}/LC_MESSAGES
  802. cd /tmp/momanager
  803. case $ATEXTDOMAIN in
  804. alsaconf)
  805. #rodin.s: xgettext does not work properly on alsaconf script, use ready-made alsaconf.pot (in Woof).
  806. cp -f /usr/share/doc/nls/alsaconf/alsaconf.pot ./
  807. ;;
  808. *)
  809. #120731 why not generalize the above. any script(s) can have a pre-existing .pot file and it will be used...
  810. if [ -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ];then
  811. cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot ./
  812. else
  813. #120731 multiple scripts may have the same TEXTDOMAIN...
  814. tdPTN="^export TEXTDOMAIN=${ATEXTDOMAIN}"
  815. EXTRASCRIPTS="$(echo "${GETTEXTSCRIPTS}" | tr ' ' '\n' | xargs -I INPUTFILE grep --files-with-matches -w "${tdPTN}" INPUTFILE | sed -e 's%SPACECHAR% %g')"
  816. if [ "$EXTRASCRIPTS" ];then
  817. echo -n "" > ./xEXTRASCRIPTS
  818. echo "$EXTRASCRIPTS" |
  819. while read ONEEXTRA
  820. do
  821. [ "$ONEEXTRA" = "" ] && continue
  822. [ ! -f "$ONEEXTRA" ] && continue #precaution.
  823. ONEBASE="$(basename "${ONEEXTRA}" .sh)"
  824. cp -f "$ONEEXTRA" ./${ONEBASE}.sh
  825. echo "${ONEBASE}.sh" >> ./xEXTRASCRIPTS
  826. done
  827. LANG=${ORIGLANG} rxvt -e xgettext -o ${ATEXTDOMAIN}.pot --no-wrap `cat ./xEXTRASCRIPTS`
  828. aPTN="s%Project-Id-Version: PACKAGE VERSION%Project-Id-Version: ${ANAME} VERSION%"
  829. bPTN="s%Content-Type: text/plain; charset=CHARSET%Content-Type: text/plain; charset=UTF-8%"
  830. cPTN="s% PACKAGE package% ${ANAME} package%"
  831. sed -i -e "$aPTN" -e "$bPTN" -e "$cPTN" ${ATEXTDOMAIN}.pot
  832. fi
  833. fi
  834. ;;
  835. esac
  836. LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot
  837. sync
  838. poptop_func "The translation file is now open in a text editor. Edit, then Save, then Quit text editor..."
  839. #130502 L18L/BK: stay in a loop if there is an error converting .po to .mo...
  840. ABORTFLG=0
  841. cp -f /tmp/momanager/${ATEXTDOMAIN}.po /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1
  842. while true ; do
  843. if [ "$POEDITOR" ];then
  844. LANG=${ORIGLANG} ${POEDITOR} /tmp/momanager/${ATEXTDOMAIN}.po
  845. else
  846. killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
  847. sleep 0.5
  848. LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po
  849. fi
  850. if diff -q /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>&1; then #130503 130506
  851. ABORTFLG=8
  852. break
  853. fi
  854. LANG=${ORIGLANG} msgfmt --output-file=- /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>/tmp/momanager/po-2-mo.err
  855. [ ! -s /tmp/momanager/po-2-mo.err ] && break
  856. 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:
  857. `cat /tmp/momanager/po-2-mo.err`
  858. NOTE: The above error message is logged to /tmp/momanager/po-2-mo.err
  859. Click the 'Fix' button to edit the .po file again...
  860. Click 'Revert' to go back to original .po file, and try again...
  861. Click 'Abort' to give up..." 0 0
  862. case $? in
  863. 0) continue ;; #Fix
  864. 3) cp -f /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po ; continue ;; #Revert
  865. *) ABORTFLG=9 ; break ;; #1=Abort
  866. esac
  867. done
  868. if [ $ABORTFLG -eq 0 ];then #130502
  869. LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=/tmp/momanager/${ATEXTDOMAIN}.mo /tmp/momanager/${ATEXTDOMAIN}.po
  870. pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo (the former being the editable translation file and the latter being the compiled translation file). If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB." 0 0
  871. ABORTFLG=$?
  872. fi
  873. case $ABORTFLG in #130502
  874. 0)
  875. cp -f /tmp/momanager/${ATEXTDOMAIN}.mo "${AMOSPEC}"
  876. #output as a tarball that user can email to pkg author...
  877. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES
  878. cp -f /tmp/momanager/${ATEXTDOMAIN}.mo /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/locale/${ATRANSLANG}/LC_MESSAGES/
  879. ASTAT="`stat --format=%y "$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  880. [ -f ${PATHPREFIX}${ASCRIPT} ] && ASTAT="`stat --format=%y "${PATHPREFIX}$ASCRIPT" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  881. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_SCRIPT=${ASTAT} SCRIPT='${ASCRIPT}' MO_FILE='${AMOSPEC}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  882. cd /root
  883. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  884. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  885. tarball_func
  886. ;;
  887. 8) #130503
  888. pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You did not change ${ATEXTDOMAIN}.po, so operation aborted." 0 0
  889. ;;
  890. 9)
  891. pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You failed to convert ${ATEXTDOMAIN}.po to an .mo file, so operation aborted." 0 0
  892. ;;
  893. *)
  894. pupdialog --background pink --backtitle "MoManager: mo create aborted" --msgbox "You have declined to use the mo file. Ok, it has been left at /tmp/momanager/${ATEXTDOMAIN}.mo and will not be used." 0 0
  895. ;;
  896. esac
  897. export LANG=$ORIGLANG
  898. exec momanager reenter
  899. ;;
  900. edit_desk|create_desk)
  901. if [ "$EXIT" = "edit_desk" ];then
  902. DESKFILE="`echo -n "$YESDESK_COMBO" | cut -f 1 -d ' '`"
  903. APKGNAME="`echo -n "$YESDESK_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
  904. cp -f -a /usr/share/applications/$DESKFILE /tmp/momanager/
  905. else
  906. DESKFILE="`echo -n "$NODESK_COMBO" | cut -f 1 -d ' '`"
  907. APKGNAME="`echo -n "$NODESK_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
  908. cp -f -a /usr/share/applications/$DESKFILE /tmp/momanager/
  909. sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" /usr/share/applications/$DESKFILE
  910. fi
  911. sync
  912. killall geany 2>/dev/null
  913. poptop_func "The menu file is now open in a text editor. Edit, then Save, then Quit text editor..."
  914. ASTAT="`stat --format=%y "/usr/share/applications/$DESKFILE" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  915. [ -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.
  916. xASTAT1="`stat --format=%Y "/usr/share/applications/$DESKFILE"`" #seconds since epoch.
  917. LANG=${ORIGLANG} defaulttexteditor /usr/share/applications/$DESKFILE
  918. xASTAT2="`stat --format=%Y "/usr/share/applications/$DESKFILE"`" #seconds since epoch.
  919. if [ "`grep 'PLEASE INSERT YOUR TRANSLATION HERE' /usr/share/applications/$DESKFILE`" != "" ];then
  920. mv -f /tmp/momanager/$DESKFILE /usr/share/applications/
  921. xASTAT2="$xASTAT1"
  922. fi
  923. if [ "$xASTAT1" = "$xASTAT2" ];then
  924. export LANG=$ORIGLANG
  925. exec momanager reenter
  926. fi
  927. /usr/lib/gtkdialog/box_splash -bg green -timeout 3 -text "The menu is being updated..." &
  928. LANG=$ORIGLANG /usr/sbin/fixmenus
  929. if [ "`pidof jwm`" != "" ];then
  930. JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
  931. if vercmp $JWMVER lt 574;then
  932. LANG=${ORIGLANG} jwm -restart
  933. else
  934. LANG=${ORIGLANG} jwm -reload
  935. fi
  936. fi
  937. cp -f /usr/share/applications/$DESKFILE /root/
  938. #add translation to tarball that user can email to pkg author...
  939. cd /root
  940. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications
  941. cp -f /usr/share/applications/$DESKFILE /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications/
  942. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} DESKTOP_FILE='/usr/share/applications/${DESKFILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  943. cd /root
  944. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  945. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  946. tarball_func
  947. export LANG=$ORIGLANG
  948. exec momanager reenter
  949. ;;
  950. edit_top|create_top) #menu categories.
  951. APKGNAME='WOOF'
  952. if [ "$EXIT" = "edit_top" ];then
  953. TOPFILE="$YESTOP_COMBO"
  954. cp -f -a /usr/share/desktop-directories/$TOPFILE /tmp/momanager/
  955. else
  956. TOPFILE="$NOTOP_COMBO"
  957. cp -f -a /usr/share/desktop-directories/$TOPFILE /tmp/momanager/
  958. sed -i -e "s%^Name=%Name[${ORIGLANG1}]=PLEASE INSERT YOUR TRANSLATION HERE\\nName=%" /usr/share/desktop-directories/$TOPFILE
  959. fi
  960. sync
  961. killall geany 2>/dev/null
  962. poptop_func "The menu-category file is now open in a text editor. Edit, then Save, then Quit text editor..."
  963. ASTAT="`stat --format=%y "/usr/share/desktop-directories/$TOPFILE" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  964. [ -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.
  965. xASTAT1="`stat --format=%Y "/usr/share/desktop-directories/$TOPFILE"`" #seconds since epoch.
  966. LANG=${ORIGLANG} defaulttexteditor /usr/share/desktop-directories/$TOPFILE
  967. xASTAT2="`stat --format=%Y "/usr/share/desktop-directories/$TOPFILE"`" #seconds since epoch.
  968. if [ "`grep 'PLEASE INSERT YOUR TRANSLATION HERE' /usr/share/desktop-directories/$TOPFILE`" != "" ];then
  969. mv -f /tmp/momanager/$TOPFILE /usr/share/desktop-directories/
  970. xASTAT2="$xASTAT1"
  971. fi
  972. if [ "$xASTAT1" = "$xASTAT2" ];then
  973. export LANG=$ORIGLANG
  974. exec momanager reenter
  975. fi
  976. /usr/lib/gtkdialog/box_splash -bg green -timeout 3 -text "The menu is being updated..." &
  977. LANG=$ORIGLANG /usr/sbin/fixmenus
  978. if [ "`pidof jwm`" != "" ];then
  979. JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
  980. if vercmp $JWMVER lt 574;then
  981. LANG=${ORIGLANG} jwm -restart
  982. else
  983. LANG=${ORIGLANG} jwm -reload
  984. fi
  985. fi
  986. cp -f /usr/share/desktop-directories/$TOPFILE /root/
  987. #add translation to tarball that user can email to pkg author...
  988. cd /root
  989. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications
  990. cp -f /usr/share/desktop-directories/$TOPFILE /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/applications/
  991. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} CATEGORY_FILE='/usr/share/desktop-directories/${TOPFILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  992. cd /root
  993. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  994. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  995. tarball_func
  996. export LANG=$ORIGLANG
  997. exec momanager reenter
  998. ;;
  999. create_sss) #BK's Simple String Substitution method.
  1000. APKGNAME="WOOF"
  1001. SSSFILE="$NOSSS_COMBO" #ex: menu_strings (located at /usr/share/sss/menu_strings/)
  1002. cp -f /usr/share/sss/$SSSFILE/$SSSFILE /tmp/momanager/$SSSFILE.$ORIGLANG1
  1003. sync
  1004. #120224 special handling req'd for doc_strings...
  1005. if [ "$SSSFILE" = "doc_strings" ];then
  1006. cp -f /usr/share/sss/$SSSFILE/$SSSFILE /usr/share/sss/$SSSFILE/$SSSFILE.$ORIGLANG1
  1007. #ask what files want to edit (instead of just cycling through all of them)...
  1008. CNT=0 ; CHKBOX_XML=""
  1009. for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
  1010. do
  1011. [ "$ASECTIONID" = "general" ] && continue
  1012. MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
  1013. TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
  1014. [ ! -f "$TARGETFILE" ] && continue #precaution.
  1015. CNT=$(($CNT + 1))
  1016. CHKBOX_XML="${CHKBOX_XML}
  1017. <checkbox><variable>CHKBOX_${CNT}_</variable><default>true</default><label>${TARGETFILE}</label></checkbox>"
  1018. done
  1019. export MMx_DLG="<window title=\"MoManager: Documentation files\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
  1020. <vbox>
  1021. <text><label>Please select the documentation files that you want to edit:</label></text>
  1022. ${CHKBOX_XML}
  1023. <hbox><button ok></button><button cancel></button></hbox>
  1024. </vbox>
  1025. </window>"
  1026. MMxRET="`$GTKDIALOGEXE --program=MMx_DLG`"
  1027. #now edit the doc files...
  1028. for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
  1029. do
  1030. [ "$ASECTIONID" = "general" ] && continue
  1031. sPTN="/^\[${ASECTIONID}\]/,/^$/p" #this is a multi-line block find expression.
  1032. CODEBLOCK="`sed -n "$sPTN" /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | sed -e '/^#/d' -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
  1033. [ ! "$CODEBLOCK" ] && continue #precaution.
  1034. #allow any character to be the 'marker' for / in the section-id...
  1035. MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
  1036. TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
  1037. [ ! -f "$TARGETFILE" ] && continue #precaution.
  1038. WHICHCHKBOX="`echo "$CHKBOX_XML" | grep "$TARGETFILE" | head -n 1 | grep -o 'CHKBOX_[0-9]*_'`"
  1039. [ "`echo "$MMxRET" | grep "$WHICHCHKBOX" | grep 'true'`" = "" ] && continue #not selected
  1040. SSS_POST_EXEC=""
  1041. eval "$CODEBLOCK" #has variables SSS_HANDLER_EDITOR, SSS_TRANSLATION_RULE, SSS_HANDLER_VIEWER [, SSS_POST_EXEC]
  1042. SSS_TRANSLATION_FILE="`echo -n "$SSS_TRANSLATION_RULE" | sed -e "s%SSSLANG1MARKER%${ORIGLANG1}%"`"
  1043. if [ "$TARGETFILE" = "$SSS_TRANSLATION_FILE" ];then
  1044. #the translation is completely replacing the english file, so make a backup of the en file...
  1045. FILETYPE="`echo -n "$TARGETFILE" | rev | cut -f 1 -d '.' | rev`" #ex: htm
  1046. ftPTN="s%\.${FILETYPE}$%-en.${FILETYPE}%"
  1047. ENFILE="`echo -n "$TARGETFILE" | sed -e "$ftPTN"`"
  1048. if [ ! -f "$ENFILE" ];then
  1049. if [ -f ${PATHPREFIX}"${TARGETFILE}" ];then
  1050. cp -f ${PATHPREFIX}"${TARGETFILE}" "$ENFILE" #get it from sfs layer, to ensure it is en.
  1051. else
  1052. cp -f "${TARGETFILE}" "$ENFILE"
  1053. fi
  1054. fi
  1055. TARGETFILE="$ENFILE"
  1056. fi
  1057. killall seamonkey 2>/dev/null
  1058. killall seamonkey-bin 2>/dev/null
  1059. killall geany 2>/dev/null
  1060. [ ! -f "$SSS_TRANSLATION_FILE" ] && cp -a -f $TARGETFILE $SSS_TRANSLATION_FILE
  1061. poptop_func "This is the original English file. Use this for reference only, do not edit. PLEASE WAIT..." orange 9
  1062. LANG=${ORIGLANG} ${SSS_HANDLER_VIEWER} "$TARGETFILE" &
  1063. dPID=$!
  1064. sleep 10
  1065. 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
  1066. xASTAT1="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
  1067. LANG=${ORIGLANG} ${SSS_HANDLER_EDITOR} ${SSS_TRANSLATION_FILE}
  1068. xASTAT2="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
  1069. kill $dPID
  1070. [ "$xASTAT1" = "$xASTAT2" ] && continue
  1071. DIRTRANSLATIONFILE="`dirname "${SSS_TRANSLATION_FILE}"`"
  1072. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}
  1073. cp -a -f "${SSS_TRANSLATION_FILE}" /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}/
  1074. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} TRANS_FILE='${SSS_TRANSLATION_FILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1075. [ "$SSS_POST_EXEC" ] && ${SSS_POST_EXEC}
  1076. 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
  1077. done
  1078. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}
  1079. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1080. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1081. cp -f /usr/share/sss/${SSSFILE}/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1082. export LANG=$ORIGLANG
  1083. exec momanager reenter
  1084. fi
  1085. killall geany 2>/dev/null
  1086. 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..."
  1087. ASTAT="`stat --format=%y "/usr/share/sss/$SSSFILE/$SSSFILE" | cut -f 1 -d ' ' | tr -d '-'`" #so can check against file version in latest Woof.
  1088. [ -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.
  1089. xASTAT1="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  1090. LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/$SSSFILE.$ORIGLANG1
  1091. xASTAT2="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  1092. if [ "$xASTAT1" = "$xASTAT2" ];then
  1093. export LANG=$ORIGLANG
  1094. exec momanager reenter
  1095. fi
  1096. [ "$SSSFILE" = "desk_strings" ] && fixdesk en #120212 translate all target files back to english. (using old $SSSFILE)
  1097. [ "$SSSFILE" = "script_strings" ] && fixscripts en #120212 translate all target files back to english. (using old $SSSFILE)
  1098. cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /usr/share/sss/$SSSFILE/
  1099. [ "$SSSFILE" = "desk_strings" ] && fixdesk $ORIGLANG1 #120212 translate all target files back to current language. (using new SSSFILE)
  1100. [ "$SSSFILE" = "script_strings" ] && fixscripts $ORIGLANG1 #120212 translate all target files back to current language. (using new SSSFILE)
  1101. /usr/lib/gtkdialog/box_splash -bg green -timeout 3 -text "The desktop and menus are being updated..." &
  1102. LANG=$ORIGLANG /usr/sbin/fixmenus
  1103. if [ "`pidof jwm`" != "" ];then
  1104. JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
  1105. if vercmp $JWMVER lt 574;then
  1106. LANG=${ORIGLANG} jwm -restart
  1107. else
  1108. LANG=${ORIGLANG} jwm -reload
  1109. fi
  1110. fi
  1111. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1112. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1113. cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1114. cd /root
  1115. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  1116. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  1117. tarball_func
  1118. export LANG=$ORIGLANG
  1119. exec momanager reenter
  1120. ;;
  1121. edit_sss)
  1122. APKGNAME="WOOF"
  1123. SSSFILE="$YESSSS_COMBO" #ex: menu_strings.de (located at /usr/share/sss/menu_strings/)
  1124. SSSFILE="`echo -n "$SSSFILE" | rev | cut -f 2-9 -d '.' | rev`" #dump the extension, ex: menu_strings.de -> menu_strings
  1125. #120224 special handling req'd for doc_strings...
  1126. if [ "$SSSFILE" = "doc_strings" ];then
  1127. #ask what files want to edit (instead of just cycling through all of them)...
  1128. CNT=0 ; CHKBOX_XML=""
  1129. for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
  1130. do
  1131. [ "$ASECTIONID" = "general" ] && continue
  1132. MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
  1133. TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
  1134. [ ! -f "$TARGETFILE" ] && continue #precaution.
  1135. CNT=$(($CNT + 1))
  1136. CHKBOX_XML="${CHKBOX_XML}
  1137. <checkbox><variable>CHKBOX_${CNT}_</variable><default>true</default><label>${TARGETFILE}</label></checkbox>"
  1138. done
  1139. export MMx_DLG="<window title=\"MoManager: Documentation files\" window_position=\"1\" resizable=\"false\" icon-name=\"${WINICON}\">
  1140. <vbox>
  1141. <text><label>Please select the documentation files that you want to edit:</label></text>
  1142. ${CHKBOX_XML}
  1143. <hbox><button ok></button><button cancel></button></hbox>
  1144. </vbox>
  1145. </window>"
  1146. MMxRET="`$GTKDIALOGEXE --program=MMx_DLG`"
  1147. #now edit the doc files...
  1148. for ASECTIONID in `grep '^\[' /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _usr_local_petget_help.htm
  1149. do
  1150. [ "$ASECTIONID" = "general" ] && continue
  1151. sPTN="/^\[${ASECTIONID}\]/,/^$/p" #this is a multi-line block find expression.
  1152. CODEBLOCK="`sed -n "$sPTN" /usr/share/sss/$SSSFILE/${SSSFILE}.${ORIGLANG1} | sed -e '/^#/d' -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
  1153. [ ! "$CODEBLOCK" ] && continue #precaution.
  1154. #allow any character to be the 'marker' for / in the section-id...
  1155. MARKERCHAR="`echo -n "$ASECTIONID" | cut -c 1`"
  1156. TARGETFILE="`echo -n "$ASECTIONID" | tr "${MARKERCHAR}" '/'`" #ex: /usr/local/petget/help.htm
  1157. [ ! -f "$TARGETFILE" ] && continue #precaution.
  1158. WHICHCHKBOX="`echo "$CHKBOX_XML" | grep "$TARGETFILE" | head -n 1 | grep -o 'CHKBOX_[0-9]*_'`"
  1159. [ "`echo "$MMxRET" | grep "$WHICHCHKBOX" | grep 'true'`" = "" ] && continue #not selected
  1160. SSS_POST_EXEC=""
  1161. eval "$CODEBLOCK" #has variables SSS_HANDLER_EDITOR, SSS_TRANSLATION_RULE, SSS_HANDLER_VIEWER [, SSS_POST_EXEC]
  1162. SSS_TRANSLATION_FILE="`echo -n "$SSS_TRANSLATION_RULE" | sed -e "s%SSSLANG1MARKER%${ORIGLANG1}%"`"
  1163. if [ "$TARGETFILE" = "$SSS_TRANSLATION_FILE" ];then
  1164. #the translation is completely replacing the english file, so make a backup of the en file...
  1165. FILETYPE="`echo -n "$TARGETFILE" | rev | cut -f 1 -d '.' | rev`" #ex: htm
  1166. ftPTN="s%\.${FILETYPE}$%-en.${FILETYPE}%"
  1167. ENFILE="`echo -n "$TARGETFILE" | sed -e "$ftPTN"`"
  1168. if [ ! -f "$ENFILE" ];then
  1169. if [ -f ${PATHPREFIX}"${TARGETFILE}" ];then
  1170. cp -f ${PATHPREFIX}"${TARGETFILE}" "$ENFILE" #get it from sfs layer, to ensure it is en.
  1171. else
  1172. cp -f "${TARGETFILE}" "$ENFILE"
  1173. fi
  1174. fi
  1175. TARGETFILE="$ENFILE"
  1176. fi
  1177. killall seamonkey 2>/dev/null
  1178. killall seamonkey-bin 2>/dev/null
  1179. killall geany 2>/dev/null
  1180. [ ! -f "$SSS_TRANSLATION_FILE" ] && cp -a -f $TARGETFILE $SSS_TRANSLATION_FILE
  1181. poptop_func "This is the original English file. Use this for reference only, do not edit. PLEASE WAIT..." orange
  1182. LANG=${ORIGLANG} ${SSS_HANDLER_VIEWER} "$TARGETFILE" &
  1183. dPID=$!
  1184. sleep 10
  1185. 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
  1186. xASTAT1="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
  1187. LANG=${ORIGLANG} ${SSS_HANDLER_EDITOR} ${SSS_TRANSLATION_FILE}
  1188. xASTAT2="`stat --format=%Y "$SSS_TRANSLATION_FILE"`" #seconds since epoch.
  1189. kill $dPID
  1190. [ "$xASTAT1" = "$xASTAT2" ] && continue
  1191. DIRTRANSLATIONFILE="`dirname "${SSS_TRANSLATION_FILE}"`"
  1192. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}
  1193. cp -a -f "${SSS_TRANSLATION_FILE}" /root/MoManager-${ORIGLANG12}-${APKGNAME}${DIRTRANSLATIONFILE}/
  1194. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} TRANS_FILE='${SSS_TRANSLATION_FILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1195. [ "$SSS_POST_EXEC" ] && ${SSS_POST_EXEC}
  1196. 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
  1197. done
  1198. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}
  1199. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1200. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1201. cp -f /usr/share/sss/${SSSFILE}/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1202. export LANG=$ORIGLANG
  1203. exec momanager reenter
  1204. fi
  1205. #sync translated sss-file with original (master) sss-file (/usr/share/sss/$SSSFILE/$SSSFILE)...
  1206. #ex: 'menu_strings' is the master (no translations in it), 'menu_strings.de' has German translations.
  1207. #(Woof developers only have to edit the master, and the translation sss-files will sync to it).
  1208. #to do this properly have to write code that analyses the sss-files by section, that is, the files
  1209. #have sections, separated by blank lines and headed by an identifier, ex "[_woof_.jwmrc]"
  1210. #note: /usr/sbin/fixmenus has example sed to extract an sss section.
  1211. echo -n "" > /tmp/momanager/$SSSFILE.$ORIGLANG1
  1212. for ASECTIONID in `grep '^\[' /usr/share/sss/${SSSFILE}/${SSSFILE} | tr -d '[' | tr -d ']' | tr '\n' ' '` #ex: general _woof_.jwmrc
  1213. do
  1214. sPTN="/^\[${ASECTIONID}\]/,/^$/p" #this is a multi-line block find expression.
  1215. ENCODEBLOCK="`sed -n "$sPTN" /usr/share/sss/${SSSFILE}/${SSSFILE} | sed -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
  1216. case $ASECTIONID in
  1217. general)
  1218. #this section is just comments, pass it straight thru...
  1219. echo '[general]' >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  1220. echo "$ENCODEBLOCK" >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  1221. echo >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  1222. ;;
  1223. *)
  1224. echo "[${ASECTIONID}]" >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  1225. #find same section in the translated sss-file...
  1226. TRCODEBLOCK="`sed -n "$sPTN" /usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1} | sed -e '/^$/d' -e '/^\[/d'`" #extracts just the relevant block of lines.
  1227. echo "$TRCODEBLOCK" | #sed -e 's%\\%\\\\%g' | #121124 pass \ thru read
  1228. while read -r ATRLINE #121124 -r then backslash is not an escape.
  1229. do
  1230. case $ATRLINE in
  1231. CODESTRING*)
  1232. eval "$ATRLINE"
  1233. OKLINE="`echo "$ENCODEBLOCK" | grep "$CODESTRING" | grep "$ENGLISH"`"
  1234. [ "$OKLINE" ] && echo "$ATRLINE" >> /tmp/momanager/$SSSFILE.$ORIGLANG1 #match, so keep it.
  1235. ;;
  1236. *)
  1237. echo "$ATRLINE" >> /tmp/momanager/$SSSFILE.$ORIGLANG1 #probably a comment line.
  1238. ;;
  1239. esac
  1240. done
  1241. #now do it the other way around...
  1242. echo "$ENCODEBLOCK" | #sed -e 's%\\%\\\\%g' | #121124 pass \ thru read
  1243. while read -r AENLINE #121124 -r then backslash is not an escape.
  1244. do
  1245. case $AENLINE in
  1246. CODESTRING*)
  1247. eval "$AENLINE"
  1248. OKLINE="`echo "$TRCODEBLOCK" | grep "$CODESTRING" | grep "$ENGLISH"`"
  1249. [ ! "$OKLINE" ] && echo "$AENLINE" >> /tmp/momanager/$SSSFILE.$ORIGLANG1 #new line not in translated sss-file, so write it (not yet translated).
  1250. ;;
  1251. esac
  1252. done
  1253. echo >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  1254. ;;
  1255. esac
  1256. done
  1257. echo >> /tmp/momanager/$SSSFILE.$ORIGLANG1
  1258. sync
  1259. killall geany 2>/dev/null
  1260. 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..."
  1261. 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.
  1262. [ -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.
  1263. xASTAT1="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  1264. LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/$SSSFILE.$ORIGLANG1
  1265. xASTAT2="`stat --format=%Y "/tmp/momanager/$SSSFILE.$ORIGLANG1"`" #seconds since epoch.
  1266. if [ "$xASTAT1" = "$xASTAT2" ];then
  1267. export LANG=$ORIGLANG
  1268. exec momanager reenter
  1269. fi
  1270. [ "$SSSFILE" = "desk_strings" ] && fixdesk en #120209 translate all target files back to english. (using old $SSSFILE)
  1271. [ "$SSSFILE" = "script_strings" ] && fixscripts en #120209 translate all target files back to english. (using old $SSSFILE)
  1272. cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /usr/share/sss/$SSSFILE/
  1273. [ "$SSSFILE" = "desk_strings" ] && fixdesk $ORIGLANG1 #120209 translate all target files back to current language. (using new SSSFILE)
  1274. [ "$SSSFILE" = "script_strings" ] && fixscripts $ORIGLANG1 #120209 translate all target files back to current language. (using new SSSFILE)
  1275. /usr/lib/gtkdialog/box_splash -bg green -timeout 3 -text "The desktop and menus are being updated..." &
  1276. LANG=$ORIGLANG /usr/sbin/fixmenus
  1277. if [ "`pidof jwm`" != "" ];then
  1278. JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
  1279. if vercmp $JWMVER lt 574;then
  1280. LANG=${ORIGLANG} jwm -restart
  1281. else
  1282. LANG=${ORIGLANG} jwm -reload
  1283. fi
  1284. fi
  1285. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} SSS_FILE='/usr/share/sss/${SSSFILE}/${SSSFILE}.${ORIGLANG1}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1286. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1287. cp -f /tmp/momanager/$SSSFILE.$ORIGLANG1 /root/MoManager-${ORIGLANG12}-${APKGNAME}/usr/share/sss/${SSSFILE}/
  1288. cd /root
  1289. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  1290. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  1291. tarball_func
  1292. export LANG=$ORIGLANG
  1293. exec momanager reenter
  1294. ;;
  1295. edit_xml|create_xml) #XML data files.
  1296. if [ "$EXIT" = "edit_xml" ];then
  1297. XMLFILE="`echo -n "$YESXML_COMBO" | cut -f 1 -d ' '`"
  1298. APKGNAME="`echo -n "$YESXML_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
  1299. else
  1300. XMLFILE="`echo -n "$NOXML_COMBO" | cut -f 1 -d ' '`"
  1301. APKGNAME="`echo -n "$NOXML_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')'`"
  1302. fi
  1303. sync
  1304. killall geany 2>/dev/null
  1305. poptop_func "The XML file is now open in a text editor. Edit, then Save, then Quit text editor..."
  1306. ASTAT="`stat --format=%y "$XMLFILE" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  1307. [ -f "${PATHPREFIX}${XMLFILE}" ] && ASTAT="`stat --format=%y "${PATHPREFIX}${XMLFILE}" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  1308. xASTAT1="`stat --format=%Y "${XMLFILE}"`" #seconds since epoch.
  1309. LANG=${ORIGLANG} defaulttexteditor "${XMLFILE}"
  1310. xASTAT2="`stat --format=%Y "${XMLFILE}"`" #seconds since epoch.
  1311. if [ "$xASTAT1" = "$xASTAT2" ];then
  1312. export LANG=$ORIGLANG
  1313. exec momanager reenter
  1314. fi
  1315. #add translation to tarball that user can email to pkg author...
  1316. cd /root
  1317. PATHXMLFILE="`dirname "$XMLFILE"`"
  1318. BASEXMLFILE="`basename "$XMLFILE"`"
  1319. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}"${PATHXMLFILE}"
  1320. cp -f "$XMLFILE" /root/MoManager-${ORIGLANG12}-${APKGNAME}"${PATHXMLFILE}"/
  1321. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_FILE=${ASTAT} CATEGORY_FILE='${XMLFILE}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1322. cd /root
  1323. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  1324. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  1325. tarball_func
  1326. export LANG=$ORIGLANG
  1327. exec momanager reenter
  1328. ;;
  1329. edit_bin|create_bin) #binary executables.
  1330. if [ "$EXIT" = "edit_bin" ];then
  1331. ABIN="`echo -n "$YESBIN_COMBO" | cut -f 1 -d '(' | rev | cut -f 2-9 -d ' ' | rev`"
  1332. ANAME="`basename "$ABIN"`"
  1333. ATRANSLANG="`echo -n "$YESBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`" #ex: de
  1334. AMO="`echo -n "$YESBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: mousecheck.mo
  1335. APKGNAME="`echo -n "$YESBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 3 -d ' '`" #ex: bluefish ex: WOOF
  1336. ATEXTDOMAIN="`basename $AMO .mo`"
  1337. else
  1338. ABIN="`echo -n "$NOBIN_COMBO" | cut -f 1 -d '(' | rev | cut -f 2 -d ' ' | rev`"
  1339. ATEXTDOMAIN="`echo -n "$NOBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ' '`"
  1340. APKGNAME="`echo -n "$NOBIN_COMBO" | cut -f 2 -d '(' | cut -f 1 -d ')' | cut -f 2 -d ' '`" #ex: bluefish ex: WOOF
  1341. FIELD2ND="`echo -n "$ORIGLANG12" | cut -f 2 -d '_'`"
  1342. 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
  1343. if [ $? -eq 0 ];then
  1344. ATRANSLANG="$ORIGLANG1"
  1345. else
  1346. ATRANSLANG="$ORIGLANG12"
  1347. fi
  1348. ANAME="`basename "$ABIN"`"
  1349. AMO="${ATEXTDOMAIN}.mo"
  1350. fi
  1351. PREFIXLOCALEDIR='/usr/share/locale' #120308
  1352. #120308 there are exceptions to /usr/share/locale. unfortunately looks like i have to hard-code those...
  1353. case $ATEXTDOMAIN in
  1354. ROX-Filer) PREFIXLOCALEDIR='/usr/local/apps/ROX-Filer/Messages' ;;
  1355. esac
  1356. AMOSPEC="${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES/${AMO}"
  1357. mkdir -p "${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES" #120308
  1358. cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATEXTDOMAIN}.pot /tmp/momanager/
  1359. cd /tmp/momanager
  1360. ROPID=0 ; POPCOL='yellow'
  1361. BINMSG="A po file is open for editing. Edit, then Save, then Quit text editor..."
  1362. if [ -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po ];then #120309 use pre-existing po file.
  1363. cp -f /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po ./${ATEXTDOMAIN}.po
  1364. 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..."
  1365. [ -f "$AMOSPEC" ] && cp -f "$AMOSPEC" /tmp/momanager/${ATEXTDOMAIN}.moOLD
  1366. else
  1367. if [ "$EXIT" = "edit_bin" ];then
  1368. cp -f "$AMOSPEC" /tmp/momanager/${ATEXTDOMAIN}.moOLD
  1369. msgunfmt "$AMOSPEC" > /tmp/momanager/${ATEXTDOMAIN}1.po
  1370. #this syncs textdomain1.po and textdomain.pot, merges to textdomain.po ...
  1371. rm -f ${ATEXTDOMAIN}.po 2>/dev/null
  1372. #130526 L18L: intltool-update fails with ROX-Filer and xdialog, but msgmerge works...
  1373. LANG=${ORIGLANG} rxvt -e msgmerge ${ATEXTDOMAIN}1.po ${ATEXTDOMAIN}.pot --output-file=${ATEXTDOMAIN}.po ; #130526 L18L
  1374. BINMSG="A mo file has been converted to an editable po file. Edit, then Save, then Quit text editor..."
  1375. #120308 intltool-update is broken with ROX-Filer.pot. need a fallback method...
  1376. if [ ! -s ${ATEXTDOMAIN}.po ];then
  1377. LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot #create po file without any translations.
  1378. LANG=${ORIGLANG} defaulttextviewer /tmp/momanager/${ATEXTDOMAIN}1.po & #warning, this must be different from defaulttexteditor!
  1379. ROPID=$!
  1380. BINMSG="BAD NEWS: the 'msgmerge' utility was unable to merge your existing translations with the pot file. Therefore, the translations are open in a separate file '${ATEXTDOMAIN}1.po' and you must paste them into '${ATEXTDOMAIN}.po' -- edit the latter only! Edit '${ATEXTDOMAIN}.po', save, then quit..."
  1381. POPCOL='LightPink'
  1382. fi
  1383. else
  1384. LANG=${ORIGLANG} rxvt -e msginit --no-wrap --locale=${ORIGLANG12} --output-file=${ATEXTDOMAIN}.po --input=${ATEXTDOMAIN}.pot
  1385. fi
  1386. fi
  1387. sync
  1388. poptop_func "$BINMSG" $POPCOL
  1389. zASTAT1="`stat --format=%Y /tmp/momanager/${ATEXTDOMAIN}.po`" #120309 modify date, seconds.
  1390. if [ "$POEDITOR" ];then
  1391. ${POEDITOR} /tmp/momanager/${ATEXTDOMAIN}.po
  1392. else
  1393. killall geany 2> /dev/null #otherwise geany will return immediately and continue executing this script.
  1394. sleep 0.5
  1395. LANG=${ORIGLANG} defaulttexteditor /tmp/momanager/${ATEXTDOMAIN}.po
  1396. fi
  1397. [ $ROPID -ne 0 ] && kill $ROPID
  1398. zASTAT2="`stat --format=%Y /tmp/momanager/${ATEXTDOMAIN}.po`" #120309 modify date.
  1399. if [ "$zASTAT1" = "$zASTAT2" ];then #120309
  1400. export LANG=$ORIGLANG
  1401. exec momanager reenter
  1402. fi
  1403. LANG=${ORIGLANG} rxvt -e msgfmt --check --output-file=/tmp/momanager/${ATEXTDOMAIN}.mo /tmp/momanager/${ATEXTDOMAIN}.po
  1404. pupdialog --background yellow --colors --backtitle "MoManager: post-edit mo" --yes-label "OK" --no-label "Cancel" --extra-button --extra-label "OK, keep po" --yesno "The file /tmp/momanager/${ATEXTDOMAIN}.po has been edited and converted to /tmp/momanager/${ATEXTDOMAIN}.mo. If all went well, click the \ZbOK\ZB button to copy it to \Zb${AMOSPEC}\ZB. Note, as a precaution, the old mo file is at /tmp/momanager/${ATEXTDOMAIN}.moOLD.
  1405. 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
  1406. RETVAL=$?
  1407. if [ $RETVAL -eq 3 ];then #extra button
  1408. cp -f /tmp/momanager/${ATEXTDOMAIN}.po /usr/share/doc/nls/${ATEXTDOMAIN}/${ATRANSLANG}.po
  1409. RETVAL=0
  1410. fi
  1411. if [ $RETVAL -eq 0 ];then
  1412. cp -f /tmp/momanager/${ATEXTDOMAIN}.mo "${AMOSPEC}"
  1413. #output as a tarball that user can email to pkg author...
  1414. mkdir -p /root/MoManager-${ORIGLANG12}-${APKGNAME}${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES
  1415. cp -f /tmp/momanager/${ATEXTDOMAIN}.mo /root/MoManager-${ORIGLANG12}-${APKGNAME}${PREFIXLOCALEDIR}/${ATRANSLANG}/LC_MESSAGES/
  1416. ASTAT="`stat --format=%y "$ABIN" | cut -f 1 -d ' ' | tr -d '-' `" #so can check against file version in latest Woof.
  1417. [ -f ${PATHPREFIX}${ABIN} ] && ASTAT="`stat --format=%y "${PATHPREFIX}$ABIN" | cut -f 1 -d ' ' | tr -d '-' `" #get orig modify date.
  1418. echo "MACTION=${EXIT} TODAY_DATE=${ADATE} ORIG_DATE_BINARY=${ASTAT} BINARY='${ABIN}' MO_FILE='${AMOSPEC}' AUTHOR='${AUTHORSPECS}'" >> /root/MoManager-${ORIGLANG12}-${APKGNAME}/write.log
  1419. cd /root
  1420. mv -f MoManager-${ORIGLANG12}-${APKGNAME}.tar.gz MoManager-${ORIGLANG12}-${APKGNAME}.tar.gzOLD 2>/dev/null
  1421. dir2tgz MoManager-${ORIGLANG12}-${APKGNAME}/
  1422. tarball_func
  1423. else
  1424. pupdialog --background pink --backtitle "MoManager: mo edit aborted" --msgbox "You have declined to update the mo file." 0 0
  1425. fi
  1426. export LANG=$ORIGLANG
  1427. exec momanager reenter
  1428. ;;
  1429. create_pet) #create a langpack PET
  1430. mv -f /root/langpack_${GENLANG}-${ADATE}.pet /root/langpack_${GENLANG}-${ADATE}.petOLD 2>/dev/null
  1431. [ -d /root/langpack_${GENLANG}-${ADATE} ] && rm -rf /root/langpack_${GENLANG}-${ADATE}
  1432. mkdir /root/langpack_${GENLANG}-${ADATE}
  1433. cp -a -f /usr/share/doc/langpack-template/* /root/langpack_${GENLANG}-${ADATE}/
  1434. echo "langpack_${GENLANG}-${ADATE}|langpack_${GENLANG}|${ADATE}||Setup|1104K||langpack_${GENLANG}-${ADATE}.pet||${GENLANG} language-pack for Puppy Linux, for any Puppy built from Woof later than Feb. 28, 2012||||" > /root/langpack_${GENLANG}-${ADATE}/pet.specs
  1435. sed -i -e "s%TARGETLANG%${ORIGLANG1}%" /root/langpack_${GENLANG}-${ADATE}/pinstall.sh
  1436. 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:
  1437. \ZbLanguage pack installed, but requires restart of X to take full effect\ZB" 0 0`"
  1438. if [ "$POSTMSG" ];then
  1439. sed -i -e "s%POSTINSTALLMSG%${POSTMSG}%" /root/langpack_${GENLANG}-${ADATE}/pinstall.sh
  1440. else
  1441. sed -i -e "s%POSTINSTALLMSG%Language pack installed, but requires restart of X to take full effect%" /root/langpack_${GENLANG}-${ADATE}/pinstall.sh
  1442. fi
  1443. cat /tmp/momanager/translations4langpack |
  1444. while read ALINE
  1445. do
  1446. ADIR="`dirname "$ALINE"`"
  1447. mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
  1448. cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
  1449. done
  1450. #130503 L18L: rename AppInfo.xml to AppInfo.xml.in for langpack (see also /usr/share/doc/langpack-template/pinstall.sh in Woof)
  1451. sync #130807 L18L
  1452. for AFILE in `ls -1 /root/langpack_${GENLANG}-${ADATE}/usr/local/apps/*/AppInfo.xml | tr '\n' ' '`
  1453. do
  1454. mv $AFILE "${AFILE}.in"
  1455. done
  1456. #120926 want to accumulate many .desktop files (not just for installed pkgs), in /usr/share/applications.in...
  1457. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in
  1458. cp -a -f /usr/share/applications.in/* /root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in/
  1459. cp -a -f /root/langpack_${GENLANG}-${ADATE}/usr/share/applications/* /root/langpack_${GENLANG}-${ADATE}/usr/share/applications.in/
  1460. rm -r -f /root/langpack_${GENLANG}-${ADATE}/usr/share/applications
  1461. 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
  1462. mv -f /root/langpack_${GENLANG}-${ADATE}/usr/share/desktop-directories /root/langpack_${GENLANG}-${ADATE}/usr/share/desktop-directories.in
  1463. #120313 offer to find more...
  1464. 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
  1465. if [ $? -eq 1 ];then
  1466. find /usr -type f -name '*.po' -o -name '*.mo' | grep "/${ORIGLANG1}[/_.]" |
  1467. while read ALINE
  1468. do
  1469. ADIR="`dirname "$ALINE"`"
  1470. mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
  1471. cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
  1472. done
  1473. find /usr -type f -name '*.pot' |
  1474. while read ALINE
  1475. do
  1476. ADIR="`dirname "$ALINE"`"
  1477. mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
  1478. cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
  1479. done
  1480. #zigbert uses t12s method. ex: /usr/local/pburn/locals/ru_RU:russian ...
  1481. find /usr/local -type f -name "${ORIGLANG1}_[A-Z][A-Z]:*" |
  1482. while read ALINE
  1483. do
  1484. ADIR="`dirname "$ALINE"`"
  1485. mkdir -p /root/langpack_${GENLANG}-${ADATE}"${ADIR}"
  1486. cp -a -f "$ALINE" /root/langpack_${GENLANG}-${ADATE}"${ADIR}"/
  1487. done
  1488. #120316 other t12s translations, refer http://bkhome.org/blog/?viewDetailed=02748 ...
  1489. if [ -d /usr/share/locales/${ORIGLANG1} ];then
  1490. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG1}
  1491. cp -a -f /usr/share/locales/${ORIGLANG1}/* /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG1}/
  1492. fi
  1493. if [ -d /usr/share/locales/${ORIGLANG12} ];then
  1494. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG12}
  1495. cp -a -f /usr/share/locales/${ORIGLANG12}/* /root/langpack_${GENLANG}-${ADATE}/usr/share/locales/${ORIGLANG12}/
  1496. fi
  1497. #120316 puppy is usually built with english hunspell dictionary. other languages can be found,
  1498. #refer: http://bkhome.org/blog/?viewDetailed=02750, refer also pinstall.sh of langpack.
  1499. for ONEHUN in `find /usr/share/hunspell -mindepth 1 -maxdepth 1 -type f -name "${ORIGLANG1}*.dic" -o -name "${ORIGLANG12}*.aff" | tr '\n' ' '`
  1500. do
  1501. HUNBASE="`basename $ONEHUN`"
  1502. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/hunspell
  1503. cp -a -f $ONEHUN /root/langpack_${GENLANG}-${ADATE}/usr/share/hunspell/
  1504. #maybe need symlinks for apps that use myspell, refer to example hunspell-en-us-2.pet ...
  1505. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/enchant/myspell
  1506. ln -snf ../../hunspell/${HUNBASE} /root/langpack_${GENLANG}-${ADATE}/usr/share/enchant/myspell/${HUNBASE}
  1507. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/myspell/dicts
  1508. ln -snf ../../hunspell/${HUNBASE} /root/langpack_${GENLANG}-${ADATE}/usr/share/myspell/dicts/${HUNBASE}
  1509. done
  1510. #120317 L18L man pages...
  1511. if [ -d /usr/share/man/${ORIGLANG1} ];then
  1512. mkdir -p /root/langpack_${GENLANG}-${ADATE}/usr/share/man/${ORIGLANG1}
  1513. cp -a -f /usr/share/man/${ORIGLANG1}/man* /root/langpack_${GENLANG}-${ADATE}/usr/share/man/${ORIGLANG1}/
  1514. fi
  1515. fi
  1516. sync
  1517. cd /root
  1518. dir2tgz /root/langpack_${GENLANG}-${ADATE}
  1519. tgz2pet /root/langpack_${GENLANG}-${ADATE}.tar.gz
  1520. sync
  1521. pupdialog --background '#8080FF' --backtitle "Langpack PET created" --msgbox "Langpack /root/langpack_${GENLANG}-${ADATE}.pet has been created." 0 0
  1522. ;;
  1523. esac
  1524. ###END###